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.

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.0.1a3.tar.gz (7.3 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.0.1a3-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

File details

Details for the file pytempl-0.0.1a3.tar.gz.

File metadata

  • Download URL: pytempl-0.0.1a3.tar.gz
  • Upload date:
  • Size: 7.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.8.11 Darwin/24.1.0

File hashes

Hashes for pytempl-0.0.1a3.tar.gz
Algorithm Hash digest
SHA256 eab2875bee228db792301fbf8d7eafb202f6b52c32e7251bc7e50b0b7d09c8c0
MD5 f6c47a67d9f5808b9761d044a790e76d
BLAKE2b-256 93f15fe8717a5abeb1fc55fca24e8f139d9f08d282b13fecfc01a5b3a5627b55

See more details on using hashes here.

File details

Details for the file pytempl-0.0.1a3-py3-none-any.whl.

File metadata

  • Download URL: pytempl-0.0.1a3-py3-none-any.whl
  • Upload date:
  • Size: 9.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.8.11 Darwin/24.1.0

File hashes

Hashes for pytempl-0.0.1a3-py3-none-any.whl
Algorithm Hash digest
SHA256 72359b04f4dd041abefb2cf1b7ffd65988344d111713665d20854f28a792016f
MD5 a8c7ed80eb17f5a5cea7d9ca22e22eb6
BLAKE2b-256 0c6d8cf12942b05400058d48f729b2e0726d4e28da7626894e2fbeb56b271f72

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