Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from tornado.template import Template
- #simple generation
- print Template("{{ 3*3 }}").generate()
- #generate using function
- def add(x,y):
- return x + y
- print Template("{{a(1,2)}}").generate(a = add)
- #generate with two functions
- def sub(x,y):
- return x-y
- print Template("{{a(1,2)}} , {{b(4,3)}}").generate(a = add,b = sub)
- #substitution within the Template statement
- text = "{{a(1,2)}} , {{b(4,3)}}"
- print Template(text).generate(a = add,b = sub)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement