Syntax highlighter failed, in laravel blade (HTML +PHP )
when i using @for (PHP) in script tag.
it is solved when i downgrade the sublime to the version 3.0 (BUILD 3143)
PHP syntax is breaking in latest version 3176
Any kind of code snippet would help to debug and reveal the context which triggers the issue.
<script>
function ab(opt)
{
var index=(parseInt(getC(“site”))>=0) ? parseInt(getC(“site”)) :0;
switch(opt)
{
@for($i=0;$i<count($s);++$i)
case {{$i}} : showTab( {{$i}}, {{ $s[$i][‘id’] }}, “{{ $s[$i][‘name’] }}”);
break;
@endfor
}
}
Using the latest Laravel Blade Highlighter package (1.6.11) everything seems fine here. I lust loaded up the above snippet and everything looks good. Have you tried a portable install with the LBH package to see if it’s working properly there?
The <script>
tag is meant to highlight pure JavaScript code, while the provided code snippet contains third-party-none-standard templates.
All builtin syntax definitions of Sublime Text provide support for the most used standard languages such as HTML, PHP, CSS, JavaScript, … , while trying to achieve best possible accuracy in identifying all the languages details, which is a quite comprehensive task already.
They do and can not provide support for all the rising templating engines or language extensions by default. This is a task of custom syntax definitions such as the mentioned Laravel package.
Indeed. Blade constructs like @for are meant to be embedded within html. That said, there is no reason why they shouldn’t work inside <script>
tags, since iirc laravel’s blade parser isn’t particularly context aware about the files it’s processing. It sees @for or {{ xxx }} and just goes ahead with substitution. To put it another way Blade doesn’t understand scopes or language context even to the extent that Sublime does: its just a substitution engine.
And that’s why, with Laravel Blade Highlighter, things are correctly highlighted even in the above example.
I may be missing the point here but has the OP actually installed LBH? I’d be surprised if blade directives would scope/colour correctly without it or something similar, in any version of sublime.