Template Data Languages - How to add PHP highlight to SMARTY?

I am using Nette framework, which uses *.latte files for html templating, I have assigned the *.latte extension under Smarty, which allows for autocomplete when writing all of the html code, but sometimes I use php snippets enclosed in <?php * ?> and they are treated as default text. Is there any way I can say that anything inside the <?php and the ?> is PHP and get the syntax highlight and autocomplete features for it?

There is also a plugin that recognizes *.latte files as their own file type. But even it only highlights HTML, but does't have autocomplete, plus php inside <?php ?> is still treated as default text, so the only thing it is good for is autocomplete and highlight of the Nette framework macros that are used inside the *.latte files. Maybe this would be easier to make work so that there is also HTML autocomplete and PHP highlight?

1 comment
Comment actions Permalink

Hi there,

AFAIK Smarty does not support <?php ?> tags directly -- only {php}.

And {php} tag is not supported (and quite unlikely to ever be -- considering that it's a bad practice as it defeats the whole point of using Smarty or any other similar templating engine -- to separate actual PHP code from presentation) -- see https://youtrack.jetbrains.com/issue/WI-1203 ticket.

ATM to have PHP code treated as PHP it should be 1) placed between <?php ?> tags and 2) file must be associated with "PHP Files" in IDE (but then you will loose Smarty). Associating it with Smarty file type removes PHP support.


Please sign in to leave a comment.