pongo2 currently supports all django 1.7 filters.
$ echo '{% for digit in "0,1,1,2,3,5,8" | stringsplit:"," %}{{digit}}\n{% endfor %}\n' | bin/tpl
0
1
1
2
3
5
8
$ echo 'Hello {{ "NAME" | getenv:"John" }}.' | NAME="Jane" bin/tpl
Hello Jane.
# can also work with default values ->
$ echo 'Hello {{ "NAME" | getenv:"John" }}.' | bin/tpl
Hello John.
kv support is based of the wonderful work the docker team did with libkv.
libkv currently supports:
- etcd
- consul
- zookeeper
- boltdb
you'll need to create the proper configuration to access a kv store.
for example:
kv:
url: "localhost:2379"
type: "etcd" # etcd | consul | zk | boltdb
connection-timeout: 10
persistent-connection: true
$ etcdctl set /person/name John
$ echo 'Hello {{ "/person/name" | kvget:"Jane" }}.' | bin/tpl --config examples/tpl.yml
Hello John.
also works with default values via kvget:DEFAULT
$ echo 'my ip is: {{ "http://api.ipify.org" | httpget }}' | bin/tpl
my ip is: 192.0.79.33
$ tmpfile=$(mktemp)
$ echo 'does the file exist? {% if "tmpfile" | getenv | pathexists %}yes{% else %}no{% endif %}' | bin/tpl
does the file exist? yes
$ echo 'tpl version: {{ "GOPATH" | getenv | stringformat: "%s/src/github.com/odedlaz/tpl/VERSION" | cat }}' | bin/tpl
# or with variable substitution -
$ echo "tpl version: {{ \"$GOPATH/src/github.com/odedlaz/tpl/VERSION\" | cat }}" | bin/tpl
tpl version: 0.1
also works with default values via cat:DEFAULT