Skip to main content

Crate oak_jinja

Crate oak_jinja 

Source
Expand description

§oak-jinja

High-performance incremental Jinja2 parser for the oak ecosystem with flexible configuration, supporting template rendering and syntax analysis.

§Features

  • Incremental Parsing: Efficiently parses only changed parts of templates
  • Flexible Configuration: Customizable syntax and behavior
  • Template Rendering Support: Built-in support for Jinja2 template rendering
  • Syntax Analysis: Detailed AST for advanced tooling
  • LSP Integration: Supports language server protocol for IDE integration

§Usage

use oak_jinja::{JinjaLexer, JinjaParser, JinjaBuilder};

let source = "Hello, {{ name }}!";
let lexer = JinjaLexer::new();
let tokens = lexer.tokenize(source);
let parser = JinjaParser::new();
let ast = parser.parse(tokens);
let builder = JinjaBuilder::new();
let root = builder.build(ast);

§Syntax Support

  • Variables: {{ variable }}
  • Blocks: {% block name %}{% endblock %}
  • Comments: {# comment #}
  • Control Structures: {% if %}, {% for %}, {% while %}
  • Macros: {% macro name() %}{% endmacro %}
  • Includes: {% include "template.html" %}
  • Extensions: {% extends "base.html" %}

§License

This project is licensed under the MIT License - see the LICENSE file for details.

Re-exports§

pub use ast::JinjaRoot;
pub use builder::JinjaBuilder;
pub use parser::JinjaParser;
pub use parser::element_type::JinjaElementType;
pub use crate::lsp::highlighter::JinjaHighlighter;
pub use crate::lsp::JinjaLanguageService;
pub use crate::lsp::formatter::JinjaFormatter;

Modules§

ast
AST module
builder
Builder module
lsp
LSP module
parser
Parser module

Structs§

JinjaLanguage
Language definition for Jinja templates
JinjaLexer
Lexer for Jinja templates

Enums§

JinjaTokenType
Token types for Jinja templates