dhilst / pynt

python formatter templating script.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

This is a simple wrapper over python string.Formatter with one difference. If the format field is not specified in the arguments the field is not parsed. This makes possible to build incremental templates.

Examples:

  • pynt 'Hello {name}' name=Daniel' -> Hello Daniel
  • pynt '{greeting} {0}' Daniel greeting=hello -> Hello Daniel
  • pynt 'Hello {name}' -> Hello {name}
  • pynt '{greeting} {name}' greeting=Hello -> Hello {name}

By passing - as first argument the template is read from the stdin:

  • pynt '{greeting} {name}' greeting=Hello | pynt - name=Daniel -> Hello Daniel

Why?

It is very useful for templating files in an incremental way. To use a file you can use process substitution from bash. pynt <(cat file) foo bar tar=zar

License: Apache 2.0

About

python formatter templating script.


Languages

Language:Python 100.0%