A Crystal implementation of the Jinja2 template engine for dynamic, runtime-evaluated templates.
Crinja is a Jinja2 template engine implementation written in Crystal. It enables dynamic template rendering at runtime, supporting features like inheritance, custom filters, and control structures. It solves the need for flexible, user-modifiable templates without requiring recompilation.
Crystal developers building web applications, configuration management tools, or any system requiring dynamic, runtime-evaluated templates.
Developers choose Crinja for its close adherence to Jinja2's proven syntax and features, combined with Crystal's performance and type safety, offering a robust alternative to compile-time template engines like ECR.
Implementation of Jinja2 template language in Crystal
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Implements most Jinja2 language features, including all built-in control structures, filters, and template inheritance, ensuring a smooth transition for developers familiar with Jinja2, as detailed in the Features section.
Evaluates templates at runtime, allowing dynamic changes without recompilation—ideal for user-defined templates or configurations, addressing limitations of compile-time engines like ECR mentioned in the Background.
Autoescape is enabled by default for HTML/XML files with configurable settings, reducing XSS risks, and supports disabling unsafe features via configuration options like disabled_filters.
Allows adding custom tags, filters, functions, and tests using macros or classes, with examples provided in the Custom Features section, enabling tailored template logic.
Missing key Jinja2 features like Python expressions, line statements, and complex numbers, and some advanced features (e.g., sandboxed execution) are only on the roadmap, limiting full compatibility.
Tied exclusively to Crystal, making it unsuitable for polyglot projects or teams not using Crystal, as highlighted by its installation via Crystal's shard.yml.
Currently fails fast with exceptions instead of collecting multiple template errors, unlike Jinjava, which can hinder debugging in complex templates, as noted in the Features section.
Runtime evaluation incurs performance costs compared to compile-time engines like ECR, a trade-off acknowledged in the Background for dynamic template needs.