Skip to content

@lost-theory /gist:3925780
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
pass mustache template into jinja template
from flask import Flask, render_template_string, request
app = Flask(__name__)
app.config['DEBUG'] = True
@app.route("/")
def index():
#of course you would put these into files
jinja_template = """
{# this is a jinja2 comment #}
{% block stuff %}
<h1>Jinja2</h1>
{% for i in range(5) %}
<p>Hello {{ name }}!</p>
{% endfor %}
<h1>Mustache</h1>
{{ mustache_template }}
{% endblock %}
"""
mustache_template = """
<p>{{something}}</p>
{{#items}}
{{#first}}
<li><strong>{{name}}</strong></li>
{{/first}}
{{#link}}
<li><a href="{{url}}">{{name}}</a></li>
{{/link}}
{{/items}}
"""
return render_template_string(jinja_template,
mustache_template=mustache_template,
name=request.values.get('name', 'world')
)
if __name__ == "__main__":
app.run(use_debugger=True, use_reloader=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.