{literal}{/literal}

Applies to: Jamroom 7.0+ Last verified: 2026-10-24
  • Why you need it

    Smarty treats { followed directly by a character as the start of a Smarty tag: {$variable}, {jrCore_list}. JavaScript and CSS use braces too, so code pasted into a template, such as an analytics snippet, can break the page:

    <script>
      function gtag(){dataLayer.push(arguments);}
    </script>
  • Here Smarty tries to read {dataLayer.push(arguments);} as a tag, and the template fails.

  • The fix

    Wrap the code in {literal} and {/literal}. Smarty leaves everything between them as it is:

    {literal}
    <script>
      function gtag(){dataLayer.push(arguments);}
    </script>
    {/literal}
  • Smarty variables inside a literal block aren't replaced either. If the script needs one, close the literal block around it, or put the value in a JavaScript variable first, outside the block.

  • Without literal

    A { followed by a space or a line break isn't a Smarty tag. So small pieces of JavaScript written like function() { ... }, with spaces, work without {literal}. For pasted code, {literal} is the safe choice.

Tags