Using strip tags in templates and stylesheets

  Previous article Next article  

Using strip tags in templates and stylesheets

  Article optimized for CMSMS 2.x

  Author:
  Last tested in: CMSMS 2.2.2
  Last updated: 03-04-2016
  Comments: 0

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

A2 Webhosting CMS Made Simple

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





A2 Webhosting CMS Made Simple

  Comments

  Click here to leave a comment






This is a captcha-picture. It is used to prevent mass-access by robots. (see: www.captcha.net)
  « Enter the CAPTCHA code (lower case)

Your IP address will be stored on submit. I reserve the right to change or delete your response without notice!
In case of abuse your IP address will be blocked!


Can I have your attention for a moment?

Did this tutorial help you solving a problem at your (clients) website and it saved you many hours of work? Great!!
Consider buying Rolf a cup of coffee in return! [ Click here ]


  0 Comments

No comments yet...

CMS Made Simple 2.2.2 - Tutorials, tips and tricks - CMSMS 2.2.2

Using strip tags in templates and stylesheets

  Article optimized for CMSMS 2.x

  Author:
  Last tested in: CMSMS 2.2.2
  Last updated: 03-04-2016
  Comments: 0

A2 Webhosting CMS Made Simple