GithubHelp home page GithubHelp logo

ykankaya / lys Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mdamien/lys

0.0 1.0 0.0 9 KB

:hibiscus: Simple HTML templating for Python

Home Page: https://pypi.python.org/pypi/lys

Python 100.00%

lys's Introduction

Lys

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

lys's People

Contributors

mdamien avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.