Search code examples
phpsmartyfatal-errorcurly-braces

Smarty templates containing inline curly brackets error


I have some code that I am working on that has inline values such as {32,15} for some JavaScript, for a client. However it always causes an fatal error, in these cases. Is there a way that I can escape the curly braces so that they do not set off any more fatal errors, and still not affect the JavaScript?


Solution

  • Put it inside {literal}...{/literal}, like so:

    {literal}
    <script>
    (function() {
        alert("Hooray for curly braces!");
    })();
    </script>
    {/literal}