There is no such thing as Twig syntax highlighting on Stack Exchange. If you want to contribute to the development yourself, join the Google Code Prettify project.

* Prove me wrong, and I will gladly delete this post.

So there has been a lot of confusion about Twig syntax highlighting in Craft Stack Exchange. To begin with, there is this post asking for the Twig highlighting to be enstated in the first place. The kindly SE employee Shog9 said that he enabled Twig highlighting... but that doesn't actually seem to be true. I've asked for clarification on that comment thread, but he hasn't had a chance to respond yet.

After that, most folks went about their business thinking that Twig syntax highlighting was automatically happening any time you used a tag. Here's what is actually happening...

Just because you type something in and it looks like it's highlighted correctly does not mean the identifier actually exists in the system. Keep in mind that invalid identifiers revert back to default. (source)

In the "default" behavior, the parser will try to automatically determine which syntax to use... basically, it's just guessing.

Here is a list of supported language syntaxes... You'll notice that Twig is not on there.

To further back up that point, here is a screenshot of the options available for auto-highlighting which can be assigned to a specific SE tag... You'll notice that Twig is not on this list either:

Tag Syntax Highlighting Options

So why isn't Twig included?

All (and I mean all) of the Stack Exchange code syntax highlighting is powered by Google Code Prettify. For a syntax to be available to SE, it must be included in the Google Code Prettify project.

You'll notice that Twig has never been mentioned in the development of this project...

But I NEED it!!

If Twig syntax highlighting is a life-changing event for you, then you really only have one option... Join the Google Code Prettify project and submit your own Twig syntax highlighting.

You must log in to answer this question.

Browse other questions tagged .