Camelcade / Perl5-IDEA

Perl5 plugins for IntelliJ IDEA
Other
409 stars 75 forks source link

Parse error in .tt #1262

Closed earandap closed 8 years ago

earandap commented 8 years ago
<script type="text/javascript">
    var a = 5;
    [% b = 4 %]
    if([% b %] <= a) {
        console.log("Hello world");
    }
</script>
hurricup commented 8 years ago

JavaScript does not parses TT part correctly. Will check it. Thanks.

hurricup commented 8 years ago

Solution is not obvious, for now you could use intermediate variable.

earandap commented 8 years ago

The file is a template .tt where I am generating some JavaScript code. The variable b is provided by a controller with dynamic value, I included the declaration for showing you consistent code.

I can use a intermediate variable, but in this project there are a lot of places where is used this snippet of code, and the code is legacy.

But don't worry, in the new code i will use a work around.

earandap commented 8 years ago

Another example.

<script type="text/javascript">
    [% comments = 1 %]
    [% IF comments # some comment here %]
     //javacript comment
    [% END %]

    function calculate(a){
    [% IF negative %]
        if( a < 0){
            alert('Negative');
            return false;
        }
    [% END %]
        return a+10;
    }

</script>
hurricup commented 8 years ago

Wow, this is nice bug :) Thanks

hurricup commented 8 years ago

Please, try http://evstigneev.com/IDEA-Perl5-2.104.zip

earandap commented 8 years ago

Nice!!! Issue solved.