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 details)

Uploaded Source

Built Distribution

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

Uploaded Python 2 Python 3

File details

Details for the file tiny_render-0.2.0.tar.gz.

File metadata

  • Download URL: tiny_render-0.2.0.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.10.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for tiny_render-0.2.0.tar.gz
Algorithm Hash digest
SHA256 8a4b90c35f8e0198727b3c9b94edff05b4a478b354f2f9795368ee7cb915683d
MD5 ec8aa8d54e41e3c748db86e3f2fb400d
BLAKE2b-256 d3949d492365696de7c8677bb92cd318ea86ab3405d440112c9c11888068ed09

See more details on using hashes here.

File details

Details for the file tiny_render-0.2.0-py2.py3-none-any.whl.

File metadata

  • Download URL: tiny_render-0.2.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 3.9 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.10.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for tiny_render-0.2.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 98bcaf97add740e1f164561fb94b66e7420752cfdd3535187ce0e0411fe69df8
MD5 26c9ee2addf40cf02c8c39836a304682
BLAKE2b-256 34e4792bd122ed3d061418fd245b541105fb59f3014611ebb189c12e1ee08311

See more details on using hashes here.

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