VS Code extension for syntax highlighting and formatting [Tera][tera] templates. Based on https://github.com/danielchatfield/atom-jinja2.
Syntax highlighting for Tera templates, embedded in 28 host languages (HTML, XML, CSS, JSON, Markdown, Python, Ruby, JavaScript, TypeScript, YAML, TOML, LaTeX, Rust and more).
Both Tera 2 and Tera 1 syntax are highlighted. Tera 2 additions include components
({% component %} / {{<name />}}), capture blocks ({% set x %}...{% endset %}),
optional chaining (a?.b), spread ({...base}), ternaries, list comprehensions, slicing
and the renamed built-in filters and tests. Tera 1 tags such as {% macro %} and
{% import %} are still highlighted so existing templates keep working.
Sample templates live in examples/: examples/tera1
for Tera 1 syntax and examples/tera2 for Tera 2. Open any of them
to see the highlighting. The Tera 2 examples are checked against the Tera 2 parser, so
they double as a reference for the new syntax.
Visual Studio Code 1.91.0 or later.
| Snippet | Description |
|---|---|
| xx | {{ }} |
| block | {% block %} {% endblock %} |
| inblock | Same as above but on a single line |
| if | {% if %} {% endif %} |
| ifi | Same as above but on a single line |
| ifelse | {% if %} {% elif %} {% endif %} |
| else | {% else %} |
| filter | {% filter %} {% endfilter %} |
| forloop | {% for in %} {% endfor %} |
| extend | {% extends "" %} |
| include | {% include "" %} |
| import | {% import "" %} |
| macro | {% macro %} {% endmacro %} (Tera 1 only) |
| Snippet | Description |
|---|---|
| component | {% component %} {% endcomponent %} |
| comp | {{<name arg="" />}} |
| compbody | {% <name> %} {% </name> %} |
| set | {% set = %} |
| setglobal | {% set_global = %} |
| setblock | {% set %} {% endset %} |
| raw | {% raw %} {% endraw %} |
| comment | {# #} |
| ternary | {{ a if cond else b }} |
| comprehension | {% set out = [x for x in items] %} |
| break | {% break %} |
| continue | {% continue %} |
- Revert 0.0.8 as it broke down Markdown files
- Snippets support in Markdown files
- Syntax highlighting of tera templates in Markdown files
- Reregister the
.teraextension - Removed the unused dependencies
- Tera template file is replaced with HTML for syntax highlighting
- Snippets work in HTML
- Added snippets support.
- Added formatting support.
- First release. May or may not be maintained.
Enjoy!
