Crate tree_sitter_rstml
source ·Expand description
This crate provides rstml (rust+html) template support for the tree-sitter parsing library.
This crate exposes two functions:
-
The language_rstml function is used to add the rstml templating language to a tree-sitter Parser. You can then use that parser to parse some code:
let code = "<div>Hello, world</div>"; let mut parser = tree_sitter::Parser::new(); parser.set_language(tree_sitter_rstml::language_rstml()).expect("Error loading rstml grammar"); let tree = parser.parse(code, None).unwrap();
-
The language_rust_with_rstml function is used to add the rust plus the rstml templating language to a tree-sitter Parser. You can then use that parser to parse some code:
let code = r#" view! { <div>hello, world</div> } "#; let mut parser = tree_sitter::Parser::new(); parser.set_language(tree_sitter_rstml::language_rust_with_rstml()).expect("Error loading rust_with_rstml grammar"); let tree = parser.parse(code, None).unwrap();
You can read more about the reason there are two grammars in the project’s README.
Constants§
- The content of the
node-types.json
file for the rstml grammar. - The content of the
node-types.json
file for the rust_with_rstml grammar.