I needed to start working with Twig recently so I had to add syntax highlighting to Sublime for it. Pretty easy and the best tutorial I found was here:
http://stackoverflow.com/questions/26294305/twig-syntax-highlighting-sublime-text-2
1. Download
The files can be downloaded from
https://github.com/Anomareh/PHP-Twig.tmbundle/archive/master.zip
or you can also clone them with:
1 |
git clone https://github.com/Anomareh/PHP-Twig.tmbundle.git |
2. Installation
To install this bundle in Sublime Text, a few extra steps are required.
a) Open Sublime Text and in the Preferences menu click Browse Packages.
b) In the directory that was just opened, create a new directory PHP-Twig/.
c) Copy the content of the repo you downloaded into the directory you just created.
d) Move the contents of the PHP-Twig/Syntaxes/ directory to PHP-Twig/ (one directory up).
e) Restart Sublime Text.
3. Apply
To apply syntax highlighting on your Twig HTML files : Open a .html.twig file Go to View menu → Syntax → Open all with current extension as → HTML (Twig).
Thank you, super easy and clear.
Great, I’m happy it helped!
Thanks, you’ve helped a lot!
Thanks a lot!
Does this also support auto indenting for twig files?
Hi Benedikt, no I don’t think it supports it.
Thank you. Right on the button.
Tom
Muchas gracias! funcionó a la perfección en 10 segundos
Yes it worked, thank you!
I have one question – is it possible to highlight items in quotes as variables elsewhere?
Hi Guntis, can you give me an example please?
Hi,
Thanks!!!
Thank you so much !
Just a quick update, you no longer need to move the contents of PHP-Twig/Syntaxes/ one directory up, it works as it is.
Thanks for the update Anpel!
Thank you very much!
How can I append a value into an array using twig? I tried:
{% set field.wrapper_attributes = field.wrapper_attributes|merge([‘has-content’]) %} but keep getting:
“Unexpected token “punctuation” of value “.” (“end of statement block” expected).”
Hi,
Try using the “merge” filter. See the documentation here: https://twig.symfony.com/doc/2.x/filters/merge.html
C’est parfait !
Thanks! Good explanation.
Thank you. Works perfect
Thanks man!
thanks, it works
Worked great, THANKS!!!
Very helpful, thanks!
Thanks Man!
Thank you!
Thank you, it works perfectly.
Thanks a lot.