Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- # Created on Fri May 9 18:02:31 2014
- # @author: Danilo de Jesus da Silva Bellini
- """ PyJade example for friends =) """
- import jinja2, sys, math
- debug = sys.argv[1:] and sys.argv[1] == "debug"
- templ = """
- !!!5
- html
- body
- - with blah = 3 * cos(pi / 6)
- .centralize
- h3
- | PyJade FTW!
- - if blah > 3
- | Blah is greater 3
- - elif blah > 2
- | Blah is in the (2; 3] interval
- - else
- | What is "blah" anyway?
- .another-div.two-classes#withID
- | Three times cosine of pi / 6 is
- = " " + blah
- """
- env = jinja2.Environment(extensions=["jinja2.ext.WithExtension",
- "pyjade.ext.jinja.PyJadeExtension"])
- # Last extension from https://github.com/mitsuhiko/jinja2-htmlcompress
- # Just save the raw jinja2htmlcompress.py file from that GitHub repository in
- # the directory from which this script would be called
- if not debug: # Call the script with a "debug" argument to avoid this
- env.add_extension("jinja2htmlcompress.HTMLCompress")
- template = env.from_string(templ)
- print template.render(pi=math.pi, cos=math.cos)
Advertisement
Add Comment
Please, Sign In to add comment