Skip to main content

A tiny renderrer for replacing place holders in any text files

Project description

Tiny Render

Unit Testing Deployment PyPI version

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 for git hash, the value will be None if git is not installed or the current directory is not a git repo.
  • {{ 'HOME' | getenv }} - the environment variable HOME will be renderred. It will raise exception if HOME is not set
  • {{ _date_str }} - the current date in yyyymmdd format
  • {{ _time_str }} - the current date/time in yyyymmddHHMMSS 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)

Uploaded Source

Built Distribution

tiny_render-0.2.0-py2.py3-none-any.whl (3.9 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page