跳转到主要内容

Python的简单HTML模板

项目描述

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

Python的简单HTML模板

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'
        ),
    ),
))

要安装,pip3 install lys

一些技巧

# 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 ''),
)

灵感 : pyxl, React

项目详情


下载文件

下载适合您平台的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。

源代码分发

lys-1.0.tar.gz (3.6 kB 查看哈希值)

上传时间: 源代码

构建分发

lys-1.0-py3-none-any.whl (3.6 kB 查看哈希值)

上传时间: Python 3

由以下支持