Skip to main content

DSL for writing HTML user interfaces in Python.

This project has been archived.

The maintainers of this project have marked this project as archived. No new releases are expected.

Project description

PyTempl

Build HTML user interfaces in Python.

Introduction

PyTempl is a DSL that lets you build HTML components as Python objects, offering a clean, component-based approach that avoids the complexities of traditional templating engines. Create reusable components that generate HTML fragments to build complex views, pages, or even entire web applications, all within your Python workflow.

Getting Started

Installation:

pip install pytempl  

Simple Example:

from pytempl.tags import H1, Div, P
from pytempl import render

page = Div(_class="container")(
    H1()("My Awesome Page"),
    P()("This is a paragraph of text.")
)

print(render(page))

This will output neatly formatted HTML.

Advanced Example: Dynamic Content and Components

from pytempl.tags import Li, Span, Ul
from pytempl import render

items = ["apple", "banana", "cherry"]
item_list = Ul()(Li()(item) for item in items)

name = "Alice"
greeting = Span()(f"Hello, {name}!")

print(render(Div()(greeting, item_list)))

This demonstrates creating dynamic content and nesting components. The output will be an HTML <div> containing a greeting and the unordered list of fruits.

Backwards Compatibility Note

This project is under active development and has not yet reached v1.0.0. This means that while we are working hard to build the best possible package, we may need to make changes that affect how your code works.

Version Stability:

  • Minor Version Updates (e.g., 0.1.x -> 0.2.x): These updates may introduce breaking changes as we refine and improve the package's functionality and APIs.
  • Patch Version Updates (e.g., 0.1.1 -> 0.1.2): These updates will maintain compatibility within the same minor version and generally include bug fixes or small enhancements.

To avoid unexpected disruptions, it is recommended to pin your dependency to a specific minor version (v0.x) and carefully review release notes before upgrading to a new minor version.

We appreciate your understanding and welcome feedback as we work towards a stable and robust v1.0.0!

License

This project is licensed under the BSD-2-Clause License

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

pytempl-0.2.0a5.tar.gz (26.8 kB view details)

Uploaded Source

Built Distribution

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

pytempl-0.2.0a5-py3-none-any.whl (97.3 kB view details)

Uploaded Python 3

File details

Details for the file pytempl-0.2.0a5.tar.gz.

File metadata

  • Download URL: pytempl-0.2.0a5.tar.gz
  • Upload date:
  • Size: 26.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.8.11 Darwin/24.2.0

File hashes

Hashes for pytempl-0.2.0a5.tar.gz
Algorithm Hash digest
SHA256 eb5144726bb68f5973bc5b9052bda3363d5d29102244aca666f1944ab7767009
MD5 88bfb0882e61f1f146785a7c165d870a
BLAKE2b-256 3170e89a23ee6ed1a1bb4fa971f613e0f566c7ddf7cb6ef63f683ae58115ddaf

See more details on using hashes here.

File details

Details for the file pytempl-0.2.0a5-py3-none-any.whl.

File metadata

  • Download URL: pytempl-0.2.0a5-py3-none-any.whl
  • Upload date:
  • Size: 97.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.8.11 Darwin/24.2.0

File hashes

Hashes for pytempl-0.2.0a5-py3-none-any.whl
Algorithm Hash digest
SHA256 69d61a5982cc632d694908839ecfe32cae5c62382216ea696ee6859f6b61d56b
MD5 0afae8bb41ab251cff6fe7e657d3b99f
BLAKE2b-256 e674db524a1790eb556b81a615944f0e06ceb62bf4ae92f4658006eee87f33fd

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