#tree-sitter #incremental-parser #jinja2 #language-parser #grammar

tree-sitter-jinja2

jinja2 grammar for the tree-sitter parsing library

10 releases

0.0.12 Mar 15, 2025
0.0.11 Mar 15, 2025
0.0.10 Aug 29, 2024
0.0.8 Jun 26, 2024
0.0.5 Dec 28, 2023

#89 in Parser tooling

Download history 151/week @ 2024-12-01 194/week @ 2024-12-08 160/week @ 2024-12-15 108/week @ 2024-12-22 109/week @ 2024-12-29 154/week @ 2025-01-05 148/week @ 2025-01-12 134/week @ 2025-01-19 145/week @ 2025-01-26 153/week @ 2025-02-02 167/week @ 2025-02-09 147/week @ 2025-02-16 153/week @ 2025-02-23 156/week @ 2025-03-02 264/week @ 2025-03-09 709/week @ 2025-03-16

1,296 downloads per month
Used in 2 crates

MIT license

79KB
2.5K SLoC

C 2.5K SLoC Rust 31 SLoC // 0.5% comments JavaScript 28 SLoC // 0.3% comments Scheme 7 SLoC

tree-sitter-jinja2

Really basic parser for really basic highlighting.

npm install
tree-sitter generate && tree-sitter parse example-file.jinja2

lib.rs:

This crate provides Jinja2 language support for the tree-sitter parsing library.

Typically, you will use the language function to add this language to a tree-sitter Parser, and then use the parser to parse some code:

let code = r#"
"#;
let mut parser = tree_sitter::Parser::new();
let language = tree_sitter_jinja2::LANGUAGE;
parser
    .set_language(&language.into())
    .expect("Error loading Jinja2 parser");
let tree = parser.parse(code, None).unwrap();
assert!(!tree.root_node().has_error());

Dependencies

~4–280KB