Hyperscript Dump
Hyperscript dump is a simple python library for turning python data into raw _hyperscript.
Installation
- Install using pip:
pip install hyperscript-dump
- Import and use
build_hyperscriptwhere needed
from hyperscript_dump import build_hyperscript
Usage
build_hyperscript turns python data into raw hyperscript.
build_hyperscript(data, name='myData')
will return hyperscript like:
"""
init
set global myData to {'key': 'value'}
then remove me
end
"""
Configuration
build_hyperscript has a set of additional keyword arguments to configure its behavior.
preserve
Type: bool | Default: False
Keeps the element the hyperscript is on in the DOM after initializing if True.
camelize
Type: bool | Default: True
"Camelizes" dictionary keys from snake case (snake_case) to camel case (camelCase) to fit JavaScript naming conventions.
flatten
Type: bool | Default: False
Each key value pair in a dictionary is assigned as a separate variable, rather than as a single object.
Note: Requires data to be a dictionary.
scope
Type: str | Default: global
Determines the scope of the hyperscript variable (global, element, or local).
event
Type: str, None | Default: init
Specifies the event that triggers assignment. The hyperscript "on" keyword should not need be provided. When set to none only the hyperscript assignment statements will be returned.
Note: If preserve is False (which it is by default), the element will not be removed until after the event is fired and values are set.
debug
Type: bool | Default: False
Logs the set variable name(s) and value(s).
Final example
build_hyperscript(data, 'myData', preserve=True, camelize=False, scope='element')
assuming data is {"my_value": 25}, the tag would output
"init set element my_data to {'my_value': 25} end"
In this example:
- The hyperscript remains in the DOM since
preserveisTrue - The keys within the dumped data remain in snake case since
camelizeisFalse - The variable is scoped to the element the hyperscript belongs to since
scopeis set to'element'
License
This project is licensed under the MIT License - see the LICENSE file for details.
Release files for hyperscript-dump 1.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| hyperscript_dump-1.0.4.tar.gz | 4.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| hyperscript_dump-1.0.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 8.7 kB
Release files / hyperscript_dump-1.0.4.tar.gz
| Download URL | hyperscript_dump-1.0.4.tar.gz |
|---|---|
| Size | 4.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f3cf99279e73c351cefce2396736e46625811f3a9c366b1537090414460b8e24
|
|
BLAKE2b-256 checksum How to use checksums |
f3e8a3c34dcd79ac3ba8871780de31da869a1009dd4ebd2d2540830665e435cb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.0
|
Release files / hyperscript_dump-1.0.4-py3-none-any.whl
| Download URL | hyperscript_dump-1.0.4-py3-none-any.whl |
|---|---|
| Size | 4.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
dd55d7158d4d56391aaac6cfdc417278f21a1cc01259b6c816d44ed8bae7a5af
|
|
BLAKE2b-256 checksum How to use checksums |
087dd61f467773741c3ad92d33c40182abbca6d8f3a76d8d68590b2e42ccdefd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.0
|