Skip to content

Instantly share code, notes, and snippets.

@bradwright
Created March 6, 2012 09:42
Show Gist options
  • Save bradwright/1985341 to your computer and use it in GitHub Desktop.
Save bradwright/1985341 to your computer and use it in GitHub Desktop.
Flask-MustacheJS integration
<!doctype html>
<html>
<head>
<title>Example</title>
<script type="text/javascript" src="{{ url_for('mustache.static', filename='mustache-loader.js') }}"></script>
{{ mustache_templates }}
</head>
<body>
</body>
</html>
<!doctype html>
<html>
<head>
<title>Example</title>
<script type="text/javascript" src="/_mustache/static/mustache-loader.js"></script>
<script type="text/x-mustache-template" id="test.mustache" charset="utf-8">
&lt;p&gt;{{ test_name }}&lt;/p&gt;
</script>
</head>
<body>
</body>
</html>
from flask import Flask, render_template
from flask.ext.mustache import FlaskMustache
app = Flask(__name__)
app = FlaskMustache.attach(app)
@app.route('/')
def index():
return render_template('index.jinja')
if __name__ == '__main__':
app.run(debug=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment