Using strip tags in templates and stylesheets
Previous article Next articleStrip white space in templates and stylesheets can improve your website in different ways. But what are the best spots to put the strip tags? I always forget it, so will post some examples here to help myself, uhh you :)
How to use
HTML Template
{process_pagedata}
{$content = "{content}" scope=global}
<!DOCTYPE HTML>
<html lang="en">
{/strip}<head>{strip}
<title>{title} | {sitename}</title>
{metadata|strip}
{cms_stylesheet|strip}
{/strip}</head>{strip}
<body>
<div id="wrapper">
{* Using Smarty tags, remarks won't show up in the generated page source! *}
<div id="header">{global_content|strip name='Header'}</div>
<div id="menu">{Navigator|strip number_of_levels='1'}</div>
<div id="content">{$content|strip}</div>
<div id="footer">{include|strip file='cms_template:Footer'}</div>
</div>
{include|strip file='cms_template:Analytics'}
</body>
</html>{/strip}
When using the |strip modifier in the {Smarty} call, there is no need to add them in the module templates.
This doesn't work for the *content* of the generated stylesheets using the {cms_stylesheet} tag, so for the...
Stylesheets
[[* Using Smarty tags, remarks won't show up in the generated stylesheets! *]]
#some_div {
font-size: 12px;
}
[[* More remarks *]]
.some_class {
font-size: 12px;
}
[[/strip]]
Known issues and pittfalls
Literal tags
Stripping white space in code wrapped in {literal}{/literal} tags won't work...
jQuery/JavaScript
Stripping white space in jQuery/JavaScript may break the function when remarks are added in the code!
Working example
Comment Form
ReviewManager
ReviewManager
0 Comments
No comments yet...