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]]

Advertisement



Ads help me to help you! Thanks!

Ads help me to help you! Thanks!


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

Click here to open the form


  0 Comments

No comments yet...

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.8
  Last updated: 18-11-2017
  Comments: 0
  http://cms.ms/VfQ9

Advertisement



Ads help me to help you! Thanks!

Ads help me to help you! Thanks!

Ads help me to help you! Thanks!