command line jinja2 template (yet another j2cli)
Project description
example
$ kamidana ../examples/readme/nginx.jinja2 --data ../examples/readme/data.json
server {
listen 80;
server_name localhost;
root /var/www/project;
index index.htm;
access_log /var/log/nginx/http.access.log combined;
error_log /var/log/nginx/http.error.log;
}
nginx.jinja2
server {
listen 80;
server_name {{ nginx.hostname }};
root {{ nginx.webroot }};
index index.htm;
access_log {{ nginx.logdir }}/http.access.log combined;
error_log {{ nginx.logdir }}/http.error.log;
}
data.json
{
"nginx": {
"hostname": "localhost",
"webroot": "/var/www/project",
"logdir": "/var/log/nginx"
}
}
example2 (–additionals)
$ kamidana --additionals=../examples/readme2/additionals.py --data=../examples/readme2/data.yaml ../examples/readme2/hello.jinja2
bye, world!!
hello.jinja2
{% if 19 is night %}
{{night}}, {{name|surprised}}
{% else %}
{{daytime}}, {{name|surprised}}
{% endif %}
additionals.py
from kamidana import (
as_filter,
as_globals_generator,
as_test,
)
@as_filter
def surprised(v):
return "{}!!".format(v)
@as_globals_generator
def generate_globals():
return {"daytime": "hello", "night": "bye"}
@as_test
def night(hour):
return 19 <= hour or hour < 3
data.yaml
name: world
0.5.0
new kamidana-batch command
changing addtionals.reader’s current working directory path
0.4.1
fix bug (multi -a option)
0.4.0
add kamidana.additionals.reader
0.3.0
add –extension option
add –dump-context option
0.2.1
rename Loader to TemplateLoader
0.2.0
–loader option is added
interfaces are defined
0.1.0
first release
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
kamidana-0.5.0.tar.gz
(7.1 kB
view hashes)
Built Distribution
Close
Hashes for kamidana-0.5.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e20fc0c850f49959253d4a91f1d031de5cf158d38215d2fcef7c70e09c00b560 |
|
MD5 | 10141dcd38ac24463dec884655b47d33 |
|
BLAKE2b-256 | fa37084798e27d239751762d48373bff5493394c76494b53bc161706ca38908b |