Jinja2 A/B testing extension
This is an A/B testing extension for Jinja. It allows you to encode experiments in your templates and renders the experiment selected by the AB_EXPERIMENT environment variable. ‘control’ is the default experiment name if AB_EXPERIMENT is not specified!
To install:
pip install jinja-ab
Enable the extension in your code like this:
import os
import jinja_ab
env = Environment(
loader=FilesystemLoader(),
extensions=[jinja_ab.JinjaAbExperimentExtension],
)
os.environ['AB_EXPERIMENT'] = 'v1'
template = env.get_template('index.html')
return template.render(context)
The template syntax is:
{% experiment control %}This is the control{% endexperiment %}
{% experiment v1 %}This is version 1{% endexperiment %}
Alternative syntax is also supported:
{% ab control %}This is the control{% endab %}
{% ab v1 %}This is version 1{% endab %}
You can also mix the two tags in a single template:
{% experiment control %}This is the control{% endexperiment %}
{% ab v1 %}This is version 1{% endab %}
Single and double quoted names are also supported!
NOTE: this extension deals with rendering the template string based on the value of AB_EXPERIMENT. It is up to you or your Jinja2 based tools to decide what to do with the result. At Mr. Senko we use this extension as part of the pelican-ab plugin.
Contributing
Source code and issue tracker are at https://github.com/MrSenko/jinja-ab
Commercial support
Mr. Senko provides commercial support for open source libraries, should you need it!
Metadata
Release files for jinja-ab 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| jinja-ab-0.3.0.tar.gz | 3.4 kB | Without provenance | Details for jinja-ab-0.3.0.tar.gz |
Release files / jinja-ab-0.3.0.tar.gz
| Download URL | jinja-ab-0.3.0.tar.gz |
|---|---|
| Size | 3.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cd8d8c2c6cbaccd79b8dcd02a0d11496edb9d039a156ba69f5d6609e10c60a87
|
|
BLAKE2b-256 checksum How to use checksums |
cf87495edffe9291fab29b53aab0c5540ce0ff3dda744f9f73e6c53e2d6cde7f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for jinja-ab 0.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.