bottlepy / bottle

bottle.py is a fast and simple micro-framework for python web-applications.
http://bottlepy.org/
MIT License
8.33k stars 1.46k forks source link

UPYTL: pure python templating #1418

Open valq7711 opened 1 year ago

valq7711 commented 1 year ago

Hi! Just want to share pip install upytl

from bottle import route, run
from upytl import UPYTL, html as h

upytl = UPYTL()

template = {
    h.Html(): {
        h.Head(): {
            h.Meta(charset='utf-8'): None
        },
        h.Body(): {
            h.Div(Class='{some_class}'):
                'Hey [[ user_name ]]! How do you do?'
        }
    }
}

@route('/hello')
@upytl.view(template)
def hello():
    return dict(some_class='super-class', user_name='Man')

run(host='localhost', port=8080, debug=True)