TornadoでJade(pyjade)を使う
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
!!! 5 | |
html(lang="ja") | |
head | |
meta(charset="utf-8") | |
title= title | |
body | |
ul | |
for item in items | |
// autoescapeがNoneに設定される | |
li {{ escape(item) }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
from pyjade.ext.tornado import patch_tornado | |
import tornado.ioloop | |
import tornado.web | |
patch_tornado() | |
class MainHandler(tornado.web.RequestHandler): | |
def get(self): | |
items = ["Item1", "Item2", "<script>alert('hello');</script>"] | |
self.render('template.jade', title="pyjade", items=items) | |
application = tornado.web.Application([ | |
(r"/", MainHandler), | |
], debug=True) | |
if __name__ == '__main__': | |
application.listen(8888) | |
tornado.ioloop.IOLoop.instance().start() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment