Link Search Menu Expand Document

Bring the powerful text template engine to your C++ project!

Jinja2C++ is a modern C++ implementation of the Python’s Jinja2 template engine.
This project was inspired by Jinja2CppLight library.


Main features of Jinja2C++:

  • Library supports C++14/17/20;
  • Supports mainstream compilers (Visual C++, gcc, clang);
  • Easy-to-use interface/Great UI;
  • Conformance to Jinja2 specification;
  • Partial support for both narrow- and wide-character strings both for templates and parameters;
  • Built-in reflection for C++ types and popular json libraries (nlohmann and rapid);
  • Powerful full-featured Jinja2 expressions with filtering (via ‘|’ operator) and ‘if’-expressions;
  • Control flow statements (‘set’, ‘filter’, ‘for’, ‘if’, ‘do’, ‘with’);
  • Templates extension (‘extends’, ‘block’);
  • Templates reuse (‘include’, ‘import’, ‘from’);
  • Macros (‘macro’, ‘call’);
  • Rich error reporting;
  • Shared template enironment with templates cache support.

View it on GitHub View it on Conan


How to get Jinja2C++

The simplest way: to get the latest conan.io package: jinja2cpp/1.2.1

Or follow the build and install instructions


About the project

Jinja2C++ is © 2018-2022 by Flex Ferrum and Ruslan Morozov.

License

Jinja2C++ is distributed by a Mozilla Public License 2.0.

Contributing

When contributing to this repository, please first discuss the change you wish to make via issue, email, or any other method with the owners of this repository before making a change.

Acknowledgments and copyrights

  • Thanks to authors of original Jinja2 specification for the exceptional work!
  • Thanks to manu343726 for CMake scripts improvement, conan.io packaging and bugs hunting and fixing.
  • Thanks to martinmoene for perfectly implemented xxx-lite libraries.
  • Thanks to vitaut for the amazing text formatting library.
  • Thanks to martinus for the fast hash maps implementation.
  • File include/jinja2cpp/value_ptr.hpp Copyright © 2017-2019 by Martin Moene
  • File src/lexertk.h Originally copyright © 2001 by Arash Partow