Skip to main content

A python template engine

Project description

PyForma

A Python template engine featuring partial substitution.

Tests

Example

from pyforma import Template

template = Template("Hello, {{ subject }}! This is {{ lib_name }}.")
assert template.unresolved_identifiers() == {"subject", "lib_name"}

template = template.substitute({"lib_name": "PyForma"})
assert template.unresolved_identifiers() == {"subject"}

print(template.render({"subject": "World"}))
#> Hello, World! This is PyForma.

Features

  • 100% Python
  • Python-like expressions in templates
  • Special-purpose environments for more expressive templates
  • Templates can be inspected for what variables need to be substituted
  • Can partially substitute variables within templates
  • Rendering with undefined variables results in an error
  • Fully statically typed

Documentation

Alternatives

  • Jinja2: The de-facto standard Python template engine. It's popular, fast, expressive and extensible, but doesn't support partial template substitution.
  • Mako: Compiles templates to Python bytecode.
  • Chameleon: HTML/XML-compatible template engine.
  • string.Template: The actual standard Python template engine. Pretty limited functionality.

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

pyforma-0.7.0.tar.gz (24.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyforma-0.7.0-py3-none-any.whl (49.7 kB view details)

Uploaded Python 3

File details

Details for the file pyforma-0.7.0.tar.gz.

File metadata

  • Download URL: pyforma-0.7.0.tar.gz
  • Upload date:
  • Size: 24.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for pyforma-0.7.0.tar.gz
Algorithm Hash digest
SHA256 2e844c71fc2c936f540d5031b9e3fe665a4635c683120c7dd8393ffe146b1ea7
MD5 98acbb1c9dbd141b50f541b5ce1319ce
BLAKE2b-256 59eec96c38a7c88ed36e9d3757ba57ee219809f9846f3a5b80711989850e780c

See more details on using hashes here.

File details

Details for the file pyforma-0.7.0-py3-none-any.whl.

File metadata

  • Download URL: pyforma-0.7.0-py3-none-any.whl
  • Upload date:
  • Size: 49.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for pyforma-0.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9aad6ab1f248676c80436f8fe6f18288c577ad3836f346973bfde1fb83fc578b
MD5 d2eb2efc7106db6e919c671c99e8271f
BLAKE2b-256 9b839a5cd11c11c3e39021b98faa3c0b7f4f73b93b46936bd7be8b71673d9745

See more details on using hashes here.

Supported by

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