tree-sitter-jinja-dialects
A tree-sitter grammar for the Jinja template language family.
Supported languages
This grammar parses the union of syntax from:
- Jinja2 (Python) - the original
- Nunjucks (JavaScript) - Mozilla's JS port, used by 11ty
- Twig (PHP) - Symfony's template engine
- Tera (Rust) - Rust port
- Inja (C++) - C++ port
- Django Templates (Python) - predecessor, subset syntax
Valid syntax from any of these languages is accepted. Both true and True
parse as booleans; both none and null parse as null literals; both
key=val and key: val work in keyword arguments.
Architecture
The grammar follows a template-first approach: it parses template
delimiters and structure, exposing text nodes for HTML injection via
queries/injections.scm.
source_file := repeat(choice(statement, output, comment, text))
Expressions
Full expression parsing with 13-level precedence, including:
- Arithmetic, comparison, logical, membership (
in/not in), identity (is/is not) - Filter chains (
x | lower | truncate(50)) - Member access (
obj.prop,obj?.prop), subscript (items[0]) - Function calls with keyword arguments and spread
- Conditional expressions (Jinja2
x if c else yand Twigc ? x : y) - Twig operators:
===,!==,??,b-and/b-or/b-xor
Statements
All standard block and inline statements:
if/elif/else/endiffor/else/endfor(with tuple unpacking, condition filter,recursive)block/endblock,macro/endmacro,call/endcallfilter/endfilter,with/endwith,autoescape/endautoescaperaw/endrawandverbatim/endverbatim(via external scanner)set(inline and block forms),extends,include,import,from,do- Catch-all
generic_tagfor custom/extension tags
Whitespace control
All delimiter pairs support - (strip) and ~ (Twig preserve-newlines):
{{- expr -}} {%- tag -%} {#- comment -#}
{{~ expr ~}} {%~ tag ~%} {#~ comment ~#}
Queries
| File | Purpose |
|---|---|
highlights.scm |
Syntax highlighting |
injections.scm |
HTML injection into text nodes |
locals.scm |
Variable definitions and references |
tags.scm |
Symbol tagging (blocks, macros) |
Usage
Neovim
-- In your tree-sitter config
require('nvim-treesitter.configs').setup {
ensure_installed = { 'jinja' },
}
Node.js
const Parser = require('tree-sitter');
const Jinja = require('tree-sitter-jinja-dialects');
const parser = new Parser();
parser.setLanguage(Jinja);
const tree = parser.parse('{{ name | lower }}');
Bindings
Pre-built bindings for C, Go, Node.js, Python, Rust, and Swift.
License
MIT
Metadata
Release files for tree-sitter-jinja-dialects 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| tree_sitter_jinja_dialects-0.1.1.tar.gz | 51.0 kB | Details |
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| tree_sitter_jinja_dialects-0.1.1-cp310-abi3-win_amd64.whl | CPython 3.10 | abi3 | Windows x86-64 | Details |
| tree_sitter_jinja_dialects-0.1.1-cp310-abi3-musllinux_1_2_x86_64.whl | CPython 3.10 | abi3 | Linux musl 1.2+ x86-64 | Details |
| tree_sitter_jinja_dialects-0.1.1-cp310-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl | CPython 3.10 | abi3 | Linux glibc 2.5+ x86-64, Linux glibc 2.17+ x86-64 | Details |
| tree_sitter_jinja_dialects-0.1.1-cp310-abi3-macosx_11_0_arm64.whl | CPython 3.10 | abi3 | macOS 11.0+ ARM64 | Details |
Total release size: 203.1 kB
Release files / tree_sitter_jinja_dialects-0.1.1.tar.gz
| Download URL | tree_sitter_jinja_dialects-0.1.1.tar.gz |
|---|---|
| Size | 51.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
27d021277ca7ac71aafabcdbe1c7f272a8966b84464bc5827fc2e26a92c0ff06
|
|
BLAKE2b-256 checksum How to use checksums |
ea54799d0e14d033ac116317b7c5aca62d7de2f8ed41f863cc1ef76ccd36c1e0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 27, 2026.
Transparency logRelease files / tree_sitter_jinja_dialects-0.1.1-cp310-abi3-win_amd64.whl
| Download URL | tree_sitter_jinja_dialects-0.1.1-cp310-abi3-win_amd64.whl |
|---|---|
| Size | 31.1 kB |
| Tags | CPython 3.10 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
338839c1229d8d78099c5e9d967b4e8186e8a30b06195cc4afa2a861ca487c99
|
|
BLAKE2b-256 checksum How to use checksums |
98a8084331241572d79a4af8da6293dfab058d43f46cfd7f11683c010ee1c54c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 27, 2026.
Transparency logRelease files / tree_sitter_jinja_dialects-0.1.1-cp310-abi3-musllinux_1_2_x86_64.whl
| Download URL | tree_sitter_jinja_dialects-0.1.1-cp310-abi3-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 45.3 kB |
| Tags | CPython 3.10 Linux musl 1.2+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
e7bff8077e4c74975128d357d63938e68b62b3683ffaa56138f4cc9172ea0e6c
|
|
BLAKE2b-256 checksum How to use checksums |
d61d4a1c6c7bf11d7b1cfdbda428d44effbcb014d8479cb6b9a2e679fa929801
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 27, 2026.
Transparency logRelease files / tree_sitter_jinja_dialects-0.1.1-cp310-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | tree_sitter_jinja_dialects-0.1.1-cp310-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 45.8 kB |
| Tags | CPython 3.10 Linux glibc 2.17+ x86-64 Linux glibc 2.5+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
86088edee16d7dee4679db24f8626091a799882dc7a7dbb5b6079ca73314951b
|
|
BLAKE2b-256 checksum How to use checksums |
1a97442df61a1815598beb581ff617e4912708993724ad7be41aaf8ea926cf50
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 27, 2026.
Transparency logRelease files / tree_sitter_jinja_dialects-0.1.1-cp310-abi3-macosx_11_0_arm64.whl
| Download URL | tree_sitter_jinja_dialects-0.1.1-cp310-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 29.8 kB |
| Tags | CPython 3.10 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
e53c23593e10bbb3ffa39c8a958e4643d112c01e2ab82ba1b8488ce5ea8dcb89
|
|
BLAKE2b-256 checksum How to use checksums |
4f90c2e7b5359311fc8db812ce0d20b72e9fe78149602fbaf87c54121d601fda
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 27, 2026.
Transparency log