Parsing Javascript in a Smarty template?

We use a lot of javascript in our smarty templates, but in PHPStorm (110.226 and earlier) it appears as plain text.  There is no color highlighting or 'helps', nor does it allow/offer me the option of injecting a langauge.  If I change the Template Data Language to javascript, it fixes this issue by invalidating almost all the html & smarty code in the template and flagging it as errors since it's out of place inside javascript (and possibly some other issues).

Is there something I'm missing, or is it possible to do this?  It's very difficlult to locate syntax problems in code the old fashioned way of simply looking at plain text.

2 comments
Comment actions Permalink

http://youtrack.jetbrains.net/issue/WI-8114

Template Data Language is for entire non-smarty file content so its inappropriate to change it in this case.
We do not support {literal} as an injectable region yet.

0
Comment actions Permalink

In case you have many javscript the better way is to separate javascript into objects and move them out of smarty templates. Then use http://code.google.com/p/minify/ to group all objects in one compressed file. This file will be cached with browser.
In some cases I used javascript in templates too. To have better syntax check I moved it from smarty template to separate file and include it to template:

 <script type="text/javascript">
     {fetch file="{$smarty.current_dir}/partner_payout_checks.js"}
     PayoutChecks = new CPayoutChecks({
          data1: {$data1},
          data2: {$data2},
     });
     PayoutChecks.url = '{$this_document}';
 </script>

0

Please sign in to leave a comment.