Jinja2 is a modern and designer-friendly templating language for Python.
10K+
pinterb/jinja2 is a docker image that bundles the following:
As an example, say I want to generate some json from the following jinja2 template:
{
{%- if do_for_fun %}
"extra_token": "{{ extra_token | default('dummy_value') }}",
{%- endif %}
"datacenter": "{{ datacenter }}",
"acl_ttl": "{{ acl_ttl }}"
}
If I run my jinja2 container to render my some.json file:
docker run -i \
-v ${MY_TEMPLATE_DIR}:/data \
-e TEMPLATE=some.json.j2 \
-e "PGID=$(id -g)" -e "PUID=$(id -u)" \
pinterb/jinja2:0.0.16 datacenter='msp' acl_ttl='30m' > ${PWD}/some.json
The rendered output would be:
{
"datacenter": "msp",
"acl_ttl": "30m"
}
Additionally, if you want to write your rendered output to the same directory as your template, just specify the file name by setting the OUT_FILE environment variable:
docker run -i \
-v ${MY_TEMPLATE_DIR}:/data \
-v ${MY_OUTPUT_DIR}:/out \
-e TEMPLATE=some.json.j2 \
-e OUT_FILE=/out/some.json \
-e "PGID=$(id -g)" -e "PUID=$(id -u)" \
pinterb/jinja2:0.0.16 datacenter='msp' acl_ttl='30m'
The key things to remember are:
Content type
Image
Digest
Size
22.1 MB
Last updated
about 9 years ago
docker pull pinterb/jinja2