Created
June 27, 2012 01:30
-
-
Save longfin/3000690 to your computer and use it in GitHub Desktop.
2012-06-27
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
from flask import Flask, render_template | |
app = Flask(__name__) | |
@app.route("/") | |
def index(): | |
return render_template("template.html", | |
msg="hello word") | |
if __name__ == "__main__": | |
for name in app.jinja_env.list_templates(): | |
template = env.get_template(name) | |
filename = template.filename | |
with open(filename) as f: | |
src = f.read().decode("utf-8") | |
ast = env.parse(src) | |
for call in ast.find_all(Call): | |
for ga in call.find_all(Getattr): | |
if ga.attr == "has_permission": | |
print call |
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
from flask import Flask, render_template | |
app = Flask(__name__) | |
@app.route("/") | |
def index(): | |
return render_template("template.html", | |
msg="hello word") | |
if __name__ == "__main__": | |
for name in app.jinja_env.list_templates(): | |
template = env.get_template(name) | |
filename = template.filename | |
with open(filename) as f: | |
src = f.read().decode("utf-8") | |
ast = env.parse(src) | |
for call in ast.find_all(Call): | |
print call |
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
from flask import Flask, render_template | |
app = Flask(__name__) | |
@app.route("/") | |
def index(): | |
return render_template("template.html", | |
msg="hello word") | |
if __name__ == "__main__": | |
for name in app.jinja_env.list_templates(): | |
print name |
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
from flask import Flask, render_template | |
app = Flask(__name__) | |
@app.route("/") | |
def index(): | |
return render_template("template.html", | |
msg="Hello World!") | |
if __name__ == "__main__": | |
app.run() |
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
from flask import Flask, render_template | |
app = Flask(__name__) | |
@app.route("/") | |
def index(): | |
return render_template("template.html", | |
msg="hello word") | |
if __name__ == "__main__": | |
for name in app.jinja_env.list_templates(): | |
template = env.get_template(name) | |
filename = template.filename | |
with open(filename) as f: | |
src = f.read().decode("utf-8") | |
ast = env.parse(src) |
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
<!DOCTYPE HTML> | |
<html> | |
<head></head> | |
<body> | |
{% if current_admin.has_permission("some.list") %} | |
<ul> | |
<li>some data here</li> | |
</ul> | |
{% endif %} | |
{% if current_admin.has_permission("some.add") %} | |
<a href="{{ url_for('.some_new_form')}}">Add</a> | |
{% endif %} | |
</body> | |
</html> |
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
<!DOCTYPE HTML> | |
<html> | |
<head></head> | |
<body> | |
{{ msg }} | |
</body> | |
</html> |
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
from jinja2 import Environment, PackageLoader | |
env = Environment(loader=PackageLoader('yourapplication', 'templates')) | |
template = env.get_template('template.html') | |
print template.render(msg="Hello World!") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment