• Blogs (9)
    • 📱 236 - 992 - 3846

      📧 jxjwilliam@gmail.com

    • Version: ‍🚀 1.1.0
  • smarty: {literal}{/literal} replaced by whitespace

    Blogs20112011-10-13


    smarty: {literal}{/literal} replaced by whitespace(’ ‘)

    In HTML templates library smarty, the {literal}{/literal} pairs are used to seperated javascript/css from Smarty templates codes.

    {literal} tags allow a block of data to be taken literally. This is typically used around Javascript or stylesheet blocks where {curly braces} would interfere with the template delimiter syntax. Anything within {literal}{/literal} tags is not interpreted, but displayed as-is. If you need template tags embedded in a {literal} block, consider using {ldelim}{rdelim} to escape the individual delimiters instead.

    Note: {literal}{/literal} tags are normally not necessary, as Smarty ignores delimiters that are surrounded by whitespace. So, Be sure your javascript and CSS curly braces are surrounded by whitespace. This is new behavior to Smarty 3. Examples:

    //1. previous:
    if (form.validationEngine({literal}{returnIsValid:true}{/literal}))
      {...}
    
    {literal}css =
      {'width':200px;'height':100px;background-color: red}{/literal}
    
    //2. now:
    if (form.validationEngine({  returnIsValid:true   })) {...}
    
    css = {   'width': 200px; 'height': 100px; background-color: red   }

    This make the codes easier to read and maintain.