V
V
Vitaly2014-03-18 21:01:31
phpstorm
Vitaly, 2014-03-18 21:01:31

Phpstorm 7: HTML with inline JS - templating statements, can they be "legitimized"?

Hello.
I am learning phpstorm after eclipse pdt. Quite often, I embed a java script into templates if it is relevant only to this place, and use the template engine constructs to change the script according to the condition, for example like this:

<script>
var callback = function(){};
{if $type == 'edit'} // конструкция шаблонизатора
    var resultobj = someEditFunc(blah, callback);
{else} // конструкция шаблонизатора
    var resultobj = someCreateFunc(blah, callback);
{/if} // конструкция шаблонизатора
</script>

In the case of eclipse, everything is simple - there (perhaps only for me) the check of the JS code embedded in HTML simply does not work and nothing bothered me ... But in phpstorm I immediately catch the error "Expression statement is not assignment or call", as- is it possible to tell the checker that these constructions are "legal" and not a java script at all?)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
omo, 2014-04-02
@omo

Try adding a type (otherwise the code is interpreted as javascript):
Alternatively, place the code in an external file (script.tpl) and include it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question