NuSphere PhpEd, Smarty {literal} blocks and syntax highlightingNuSphere PhpEd, Smarty {literal} blocks and syntax highlighting

Posted January 4th, 2010 in PHP

I recently upgraded to NuSphere PhpEd 5.9 and noticed that some {literal} blocks in a Smarty template did not have any syntax highlighting. I am not sure if this was the case previously for the same section of code but worked out the location of the {literal} tags needed to be moved for syntax highlighting to work.

Incorrect usage

This first example shows how the original section of code was formatted. In PhpEd 5.9 the code in the <script> section would be greyed out like a comment and not contain any syntax highlighting:

{literal}
<script type="text/javascript">

    function somefunction() {
        var foo = 'bar';
        // there's no sytax highlighting here
        // and everything is greyed out
    }

</script>
{/literal}

Correct usage

The second correct example shows how the {literal} block should be inside the <script> tags. Once this is done the Javascript syntax highlighting will work as expected.

<script type="text/javascript">
{literal}

    function somefunction() {
         var foo = 'bar';
        // that's better, now there's syntax highlighting
    }

{/literal}
</script>

Related posts:

Comments

blog comments powered by Disqus