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"}))  # Prints "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.5.0.tar.gz (21.5 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.5.0-py3-none-any.whl (37.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pyforma-0.5.0.tar.gz
  • Upload date:
  • Size: 21.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.4

File hashes

Hashes for pyforma-0.5.0.tar.gz
Algorithm Hash digest
SHA256 578686ea945ed5b5d3aaef11e0b90e4d2390823ca74c39c87d19e8809d120d49
MD5 2df2b642ec4d350d07aa2f542090d600
BLAKE2b-256 c2e73ec13024df2a96179e4f003e6de87c2888e98a33bac9eed0c8adf2f3f979

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pyforma-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 37.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.4

File hashes

Hashes for pyforma-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e09d1f22c4cc87ca22ded44e55ddf7094998e67101ec8eebb1b8eb800046fbfd
MD5 a1eb2a4c528cf205620243fb13d29bab
BLAKE2b-256 ec8f34db067a279bfb4e76287ba53bbebece4ba83b9ba86476063c28cf53a5fb

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