https://github.com/mdamien/lys
:hibiscus: Simple HTML templating for Python
https://github.com/mdamien/lys
Last synced: 4 months ago
JSON representation
:hibiscus: Simple HTML templating for Python
- Host: GitHub
- URL: https://github.com/mdamien/lys
- Owner: mdamien
- Created: 2016-09-05T15:13:54.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2020-02-20T11:51:19.000Z (about 5 years ago)
- Last Synced: 2024-12-06T16:17:30.012Z (4 months ago)
- Language: Python
- Homepage: https://pypi.org/project/lys/
- Size: 11.7 KB
- Stars: 77
- Watchers: 6
- Forks: 4
- Open Issues: 2
-
Metadata Files:
- Readme: README.rst
- Changelog: CHANGELOG
Awesome Lists containing this project
- awesome-python-html - mdamien/lys
- awesome-python-html - mdamien/lys
README
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('alert("boo")')# attributes '_' are replaced with '-'
L.button(data_id="123") / 'click me'
# => click me# 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 `_