{tidy}
Rewrites the HTML it wraps as tidied, indented markup through PHP's tidy extension.
Syntax
{tidy} ... {/tidy}
Description
{tidy} renders its content first - fields and tags inside resolve as usual - and then passes the result through PHP's tidy extension as a fragment: unclosed elements are closed, the markup is repaired and indented by the settings of $padTidyConfig. Only the body of the fragment comes back, never a <html> around it.
The content of a <textarea>, of a <template> and of a custom element is held out of the pass and put back unchanged, so a form value keeps its whitespace and a component's markup is not rewritten.
Without the tidy extension the content is returned untouched - the result depends on the server, which is why the example is shown rather than run. The tidy option does the same for any tag ({items tidy}...{/items}), and $padTidy in the configuration tidies whole pages. To only take out whitespace between tags, use {spaceless}, which needs no extension.
Examples
Repaired and indented
The unclosed list items are closed and the list is written one element per line.
{tidy}
<ul><li>Coffee<li>Tea<li>Milk</ul>
{/tidy}
See also
- {spaceless} Takes out the whitespace between HTML tags, and at both ends of the content.
- {output} Switches how the running request answers - a web page, the console, a file, a download, JSON or CSV.
- {flush} Sends the page rendered so far to the browser at once, so it can load the stylesheets while a slow part below renders.