$ show pantor/inja
Inja is a header-only C++ template engine that renders Jinja2-like templates using JSON data. It provides a full-featured templating language including variables, loops, conditionals, template inheritance, includes, custom callbacks, whitespace control, and HTML autoescape. The library is built on top of nlohmann/json and requires C++17. It is distributed as a single-include header or via package managers. The architecture is clean: an Environment class orchestrates parsing (lexer + parser into AST) and rendering (evaluator with built-in and user-defined functions). Extensive unit tests and benchmarks ensure correctness and performance. The library is actively maintained with CI across multiple compilers and platforms.
The LLM identified 1 files worth highlighting for reuse:
Implements a registry for built-in and user-defined template functions. Supports fixed and variadic arguments, argument count validation, and both value-returning and void callbacks. The pattern is self-contained and could be extracted for use in other scripting or expression evaluation engines by replacing the json value type with a generic template parameter.