Skip to main content

Simple HTML templating for Python

Project description

Simple HTML templating for Python

from lys import L

print(L.body / (
    L.h1 / 'What is love ?',
    L.ul / ( / 'Something in the air', / 'You can\'t catch it', / (
            L.a(href="") / '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.a( /
        ) for recipe in recipes)
    ) if len(recipes) > 0 else ''),

Inspiration : pyxl, React

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for lys, version 1.0
Filename, size File type Python version Upload date Hashes
Filename, size lys-1.0-py3-none-any.whl (3.6 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size lys-1.0.tar.gz (3.6 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page