Skip to main content

Simple HTML templating for Python

Project description

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

Project details


Download files

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

Source Distribution

lys-1.0.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

lys-1.0-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

Details for the file lys-1.0.tar.gz.

File metadata

  • Download URL: lys-1.0.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for lys-1.0.tar.gz
Algorithm Hash digest
SHA256 ffb3432873d8fb9b8a995044cb92f8aecde65169770833859b51fcf4c048d9a9
MD5 10b3ed67e3a70c1d3b1590603dfb8881
BLAKE2b-256 36fc741fd2f46898494076220e6a77777c12d51ab262243f33cd07e9a3866abf

See more details on using hashes here.

File details

Details for the file lys-1.0-py3-none-any.whl.

File metadata

  • Download URL: lys-1.0-py3-none-any.whl
  • Upload date:
  • Size: 3.6 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.0.1 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.7

File hashes

Hashes for lys-1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b7b0ad08aedcc52d17b8d1d6fc220210a56bb78de389a01e93baeffc8a085bf4
MD5 9988aac48d2e2f71c767f95c03a83360
BLAKE2b-256 4b511bc4f928cf2b6020e6ecb119ec109bec3d109052fdab23f38121e2604a8b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page