In needing html templates with embedded javascript on a PHP project I was not satisfied with any solutions I found, so, with Lodash and some regex I created the following solution :
Template:
<script id="profile_greeting" type="text/template">
<h1>Hello</h1><br>
My name is <b><@=this.name@></b><br>
<@ var today = "" + new Date(); @>
The date is : <@= today @>
</script>
Lodash settings :
_.templateSettings = {
interpolate: /\<\@\=([\s\S]+?)\@\>/g,
escape: /\<\@\-([\s\S]+?)\@\>/g,
evaluate: /\<\@([\s\S]+?)\@\>/g
};
Question:
How do I setup PHPStorm to treat any code inside <@ @> and <@= @> as Javascript (syntax highlight, code completion, etc) while treating the outside as HTML ?
Note:
Code inside should be treated as HTML, and <@ @> pieces should only be treated as javascript when inside this type of tag.