This project tests compatibility of Jinja2 template language with Nunjucks and Twig.
Jinja2 (Python) introduced an expressive template language. It has since been adapted by other template engines (languages): Nunjucks (JavaScript), Twig (PHP) and others. While the template syntax between these implementations is very similar, they do have their differences. This project uses a single set of tests, generates the output with all template engines separately, and then compares the output.
You can browse the test results online. In addition all raw data is available as JSON:
- Test templates grouped by feature.
- Test data passed to templates.
- Results of tests per template engine.
- Error logs of tests per template engine.
- Versions of languages and engines used.
- Documentation references of all template features for all engines.
This project aims to cover all features of the templating language(s). The test setup consists of:
- 1 shared set of test files for all template features
- a render script for each template engine (see below)
All scripts render the tests to output/
in a directory per template engine. The output file has the same name as the test file, but with the rendered result. If a render error occurs an error log file is written to the tests output destination instead.
The Jinja2 setup requires Python (>= 3.3) and pip3
(comes with Python3) to be installed. Then install dependencies:
pip3 install -r requirements.txt
Render all tests to output/jinja2/
:
python3 test-jinja2.py
The Nunjucks setup requires NodeJS (>= 6.0) and npm (comes with Node) to be installed. Then install dependencies:
npm install
Render all tests to output/nunjucks/
:
node test-nunjucks.js
The Twig setup requires PHP (>= 5.5.9) and Composer to be installed. Then install dependencies:
composer install
Render all tests to output/twig/
:
php test-twig.php
The Swig setup requires NodeJS (>= 6.0) and npm (comes with Node) to be installed. Then install dependencies:
npm install
Render all tests to output/swig/
:
node test-swig.js
The Django setup requires Python (>= 3.3) and pip3
(comes with Python3) to be installed. Then install dependencies:
pip3 install -r requirements.txt
Render all tests to output/django/
:
python3 test-django.py
- Tests for all templating features and all their use cases
- UI to compare output of templating engines
- Add more templating engines (Jinjava (Java), Pongo (Go Lang), ...)