Version: 0.2.0
This is a very simple wrapper for Jinja2 by providing few built-in variables.
Additional variables for the Template,
{{ _gitsha }}- will be the shortsha forgithash, the value will beNoneifgitis not installed or the current directory is not a git repo.{{ 'HOME' | getenv }}- the environment variableHOMEwill be renderred. It will raise exception ifHOMEis not set{{ _date_str }}- the current date inyyyymmddformat{{ _time_str }}- the current date/time inyyyymmddHHMMSSformat
pip install tiny-renderSample Code
from tiny_render import Render
with open(os.path.join("/tmp","test.txt"), 'w') as f:
f.write("gitsha: {{_gitsha}}, hello {{key}}")
params = {"key": "world"}
r = Render("/tmp")
r.go("test.txt", **params)
# the output is "gitsha: xxxxxxx, hello world"