We heavily use Smarty for all our front end templating. I have observed the following situation:
When my Smarty template is similar to as follows:
<li>
{if $a == 'A'}
{$var1}
{else}
{$var2}
{/if}
<br><span>SUBTEXT</span>
</li>
The final HTML which is delivered to the browser is:
<li>
65
<br><span>SUBTEXT</span>
</li>
I would expect it to be more clean and something like:
<li>
65<br><span>SUBTEXT</span>
</li>
or better:
<li>65<br><span>SUBTEXT</span></li>
Anyway I can do this with some configuration settings in Smarty 3? Any setting to format and clean the final HTML created?
Thanks
You can load the output filter trimwhitespace. It removes HTML comments (except ConditionalComments) and reduces multiple whitespace to a single space everywhere but
<script>,<pre>,<textarea>.You can easily make the filter remove space between
<two> <tags>by altering line 62. changeto
and you’re done.
Output filters run AFTER the template is rendered and BEFORE it’s sent to the browser.
{strip}runs before the template is processed – it’s a compile-time thing. So the followingwill output
while the outputfilter would return