Skip to main content

Lys

https://img.shields.io/pypi/v/lys.svg https://travis-ci.org/mdamien/lys.svg?branch=master

Simple HTML templating for Python

from lys import L

print(L.body / (
    L.h1 / 'What is love ?',
    L.ul / (
        L.li / 'Something in the air',
        L.li / 'You can\'t catch it',
        L.li / (
            L.a(href="https://en.wikipedia.org/wiki/Love") / 'Keep trying'
        ),
    ),
))

To install, pip3 install lys

A few more tricks:

# raw() to mark the content as already escaped
from lys import raw
L.p / raw('<script>alert("boo")</script>')

# attributes '_' are replaced with '-'
L.button(data_id="123") / 'click me'
# => <button data-id="123">click me</button>

# shortcut to add classes and ids easily
L.button('#magic-button.very-big', onclick='add_it()') / 'Magic !'

# one easy way to do loops and ifs
(
    L.h1 / 'Welcome',
    (L.ul / (
        'Try one of our recipes:',
        (L.li / (
            L.a(href=recipe.link) / recipe.name
        ) for recipe in recipes)
    ) if len(recipes) > 0 else ''),
)

Inspiration : pyxl, React

Metadata

Release files for lys 1.0

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

Source distribution (sdist)

Source distribution for lys 1.0
File Size Uploaded
lys-1.0.tar.gz 3.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for lys 1.0
File Interpreter ABI Platform
lys-1.0-py3-none-any.whl Python 3 none any Details

Total release size: 7.2 kB

Release files / lys-1.0.tar.gz

Download URL lys-1.0.tar.gz
Size 3.6 kB
Tags Source
SHA-256 checksum
How to use checksums
ffb3432873d8fb9b8a995044cb92f8aecde65169770833859b51fcf4c048d9a9
BLAKE2b-256 checksum
How to use checksums
36fc741fd2f46898494076220e6a77777c12d51ab262243f33cd07e9a3866abf
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.0.1 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.7

Release files / lys-1.0-py3-none-any.whl

Download URL lys-1.0-py3-none-any.whl
Size 3.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b7b0ad08aedcc52d17b8d1d6fc220210a56bb78de389a01e93baeffc8a085bf4
BLAKE2b-256 checksum
How to use checksums
4b511bc4f928cf2b6020e6ecb119ec109bec3d109052fdab23f38121e2604a8b
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.0.1 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.7

Release history Release notifications | RSS feed

This release

1.0 This release

2 release files

0.3

1 release file

0.2

1 release file

0.1

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