Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Hyperscript Markup Language Python Extension

An extension to the Python language with an f-string-like template syntax for writing HTMl inspired by pyxl:

# coding=html

def html(tag, props, children):
    return (tag, props, children)

size = "30px"
text = "Hello!"

model = html"""
<div height={size} width={size} >
    <p>{text}</p>
</div>
"""

HTML Template Usage

Every file that uses the HTML template syntax must:

  1. Have an html encoding indicator as its first or second line.
  2. Define a callable html(tag, props, children) in the module.

So your files should all start a bit like this:

# coding=html
def html(tag, props, children): ...

If you haven't permanently installed the language extension you'll need to import modules with HTML Template Syntax, you'll need to make sure idom has been imported at your application's entry point to register the language extension before importing your module:

import htm_pyx
import my_project

Where my_project.py would have the following contents:

# coding=html

def html(tag, props, children):
    ...

cool_stuff = html"<div>...</div>"

HTML Template Syntax Installation

If you want to more permanently install the language extension you can run the console command:

htm-pyx register

Which can be undone (if desired) later:

htm-pyx deregister

This is optional, because you can always import htm_pyx at the root of your application to enable the extension. After this initial import all the follow with coding=html will be appropriately transpiled.

Additional Support For HTML Template Syntax

You won't be able to use the HTML template syntax directly in Python's default REPL, but it will work out of the box with:

  1. Jupyter
  2. IPython

Metadata

Release files for htm-pyx 0.1.0.dev0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for htm-pyx 0.1.0.dev0
File Interpreter ABI Platform
htm_pyx-0.1.0.dev0-py3-none-any.whl Python 3 none any Details

Release files / htm_pyx-0.1.0.dev0-py3-none-any.whl

Download URL htm_pyx-0.1.0.dev0-py3-none-any.whl
Size 9.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d662634aa1729da74093067369d905b9bde7bf1b881f6ecd92ceb1f7a315a978
BLAKE2b-256 checksum
How to use checksums
23e3949d0d4ddee4ead94857e365a93e63be4673895706383bfed0991775e9a8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.9

Release history Release notifications | RSS feed

This release

0.1.0.dev0 This release

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page