Control the web with Python
Project description
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:
- Have an
htmlencoding indicator as its first or second line. - 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:
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file htm_pyx-0.1.0.dev0-py3-none-any.whl.
File metadata
- Download URL: htm_pyx-0.1.0.dev0-py3-none-any.whl
- Upload date:
- Size: 9.3 kB
- Tags: Python 3
- Uploaded using 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
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d662634aa1729da74093067369d905b9bde7bf1b881f6ecd92ceb1f7a315a978
|
|
| MD5 |
f57acfd0f58bdf4c34ac537d72daa7e3
|
|
| BLAKE2b-256 |
23e3949d0d4ddee4ead94857e365a93e63be4673895706383bfed0991775e9a8
|