Skip to content

Instantly share code, notes, and snippets.

@yukirin
Last active December 22, 2016 08:57
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save yukirin/c7eff92d9687f2cd2486 to your computer and use it in GitHub Desktop.
TornadoでJade(pyjade)を使う
!!! 5
html(lang="ja")
head
meta(charset="utf-8")
title= title
body
ul
for item in items
// autoescapeがNoneに設定される
li {{ escape(item) }}
#!/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