Sublime Text syntax highlight Jinja2 [closed]
Asked Answered
B

1

22

Is there syntax highlight for Jinja2 templates in Sublime Text? By Jinja2 I mean:

{% extends "template.html" %}
{% block content %}
{% if task == 'archimed_spiral' %}
    {% include 'archimed.html %}
{% elif task == 'gcd' %}
    {% endif %}
{% endblock %}

I believe it is based on Python. And it can be pretty hard to read.

Backlog answered 4/4, 2014 at 18:41 Comment(0)
C
33

Yes, there is a Jinja2 package for Sublime Text.

It is implemented as a TextMate syntax bundle; these are directly supported by Sublime Text, and was written by the author of the Jinja2 package himself.

Conjunction answered 4/4, 2014 at 18:42 Comment(5)
Thanks, I will try it - does it highlight also the html syntax?Backlog
There are two modes: Jinja Templates and HTML (Jinja Templates). The latter is a full HTML mode plus Jinja syntax.Conjunction
Works nicely, although it might be better to use different colors for Jinja2 and html.. Now it kinda blurs together. But I guess it is better than before. I'll accept the answer as soon as I can.Backlog
@MartijnPieters How do you set it in Sublime that it always opens .html as a HTML (Jinja Templates)Triglyph
@Wavesailor: with a .html file open, use View -> Syntax -> Open all with current extension as... -> Jinja2 -> HTML (Jinja2). See How to customise file type to syntax associations in Sublime Text?Conjunction

© 2022 - 2024 — McMap. All rights reserved.