Get syntax highlight for Jinja2-like template in Komodo

If you build website in Python, there is high chance that you use Jinja2 for template. If your favourite IDE is Komodo Edit, how to get syntax highlight support?

Currently, Komodo Edit doesn't support Jinja2, even there is a long standing request. Some people use Django highlighter for it but it does not work well.

But there is a template language with syntax very similar to Jinja2, which not many Python developer know, is supported by Komodo. It is Twig, a PHP one and used in Symfony, Drupal. Twig's syntax resembles Jinja2 more than Django, with "function call" style and macro:

{% import "forms.html" as forms %}

<p>{{ forms.input('username') }}</p>

So, to get syntax highlight for your Jinja2 file, just set its "file type" as Twig in Komodo.

This trick can be applied for other Jinja2-like template engines like: Swig, Nunjucks, Liquid etc.


I made an add-on for Komodo Edit to support Jinja2. Grab the source here: