A tiny renderrer for replacing place holders in any text files
Project description
Tiny Render
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 forgit
hash, the value will beNone
ifgit
is not installed or the current directory is not a git repo.{{ 'HOME' | getenv }}
- the environment variableHOME
will be renderred. It will raise exception ifHOME
is not set{{ _date_str }}
- the current date inyyyymmdd
format{{ _time_str }}
- the current date/time inyyyymmddHHMMSS
format
Installation
pip install tiny-render
Sample 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"
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
tiny_render-0.2.0.tar.gz
(3.9 kB
view hashes)
Built Distribution
Close
Hashes for tiny_render-0.2.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 98bcaf97add740e1f164561fb94b66e7420752cfdd3535187ce0e0411fe69df8 |
|
MD5 | 26c9ee2addf40cf02c8c39836a304682 |
|
BLAKE2b-256 | 34e4792bd122ed3d061418fd245b541105fb59f3014611ebb189c12e1ee08311 |