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

Jinja2C++ is a modern C++ implementation of the Python Jinja2 template engine. Originally, it was inspired by Jinja2CppLight library and now Jinja2C++ brings support for mostly all Jinja2 templates engine features into C++ world.

Main features of Jinja2C++:

  • C++14/17 library
  • 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 package: jinja2cpp/0.9.1@Manu343726/testing

Or follow the build and install instructions

About the project

Jinja2C++ is © 2018-2019 by Flex Ferrum.


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


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, 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