Is there something wrong with wrapping whole Smarty patterns in {strip} tags?

I want my templates to be neat and beautiful, but I would like to deliver only a very compact HTML file to the browser. Lacking a better idea, I was wondering if something was wrong with wrapping all Smarty templates in tags {strip}like this?

{strip}
        <div class="albums">
            <h2>Alle Foto-Alben</h2>

            <ul class="photos clearfix">
                {foreach $albums as $album}
                    {if $album->publishedPhotos|count > 0}
                    <li>
                        <div>
                            <a href="album.php?id={$album->id}">
                                <img src="{$album->titlepic->thumb}" alt="{$album->titlepic->title}" />
                                <span class="title">{$album->title}</span>
                                <span class="counter">{$album->publishedPhotos|count} Foto{if $album->publishedPhotos|count != 1}s{/if}</span>
                            </a>
                        </div>
                    </li>
                    {/if}
                {/foreach}
            </ul>
        </div>
{/strip}

It smells a bit unprofessional for me, but I couldn't think of anything better.
One drawback definitely is that you have to wrap each of your templates in those tags.

I am glad that it has been fixed and would like to hear different approaches to maintaining compact code.

+3
source share
3 answers

, .

/ , .

PHP.

+1

, . ( ), {strip}. , . .

/* Minify the html */
function smarty_pre_minify($tpl_source, $smarty) { return preg_replace('/[ \t\n\r]+/s', ' ', $tpl_source); }
$smarty->registerFilter('pre', 'smarty_pre_minify');
+5

Note: The list is ignored by the Striptags. Endless day. :-)

+1
source

Source: https://habr.com/ru/post/1758826/


All Articles