MENU

Using strip tags in templates and stylesheets

  Previous article Next article  

Strip 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

{strip}
    {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

[[strip]]

[[* 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





Buy Me A Coffee


  Comment Form

ReviewManager

Click here to open the form

ReviewManager

  0 Comments

No comments yet...

Buy Me A Coffee

CMS Made Simple - Tutorials, Tips and Tricks - CMSMS

Using strip tags in templates and stylesheets

  Article optimized for CMSMS 2.x

  Author:
  Last tested in: CMSMS 2.2.19
  Last updated: 10-06-2019
  Comments: 0
  http://cms.ms/VfQ9


Buy Me A Coffee




Advertisement


Ads help me to help you! Thanks!

Ads help me to help you! Buy products from these advertisers!