Lys
:hibiscus: Simple HTML templating for Python
Install / Use
/learn @mdamien/LysREADME
Lys
.. image:: https://img.shields.io/pypi/v/lys.svg :target: https://pypi.python.org/pypi/lys .. image:: https://travis-ci.org/mdamien/lys.svg?branch=master :target: https://travis-ci.org/mdamien/lys
Simple HTML templating for Python
.. code:: 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, :code:pip3 install lys
A few more tricks:
.. code:: python
# 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 <https://github.com/dropbox/pyxl>, React <https://facebook.github.io/react/>
Related Skills
node-connect
339.1kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
83.8kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
339.1kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
commit-push-pr
83.8kCommit, push, and open a PR
