While I fundamentally agree with the way @Miguel and @Ali, several companies I worked with are mixing the RESTful API model with server-side HTML. [ NOTE: This should not be the case when using Ember, but I work with Flask / Jinja2 and Backbone in my current client code base.]
I really found a solution using Pybars , based on some reading from the Khan Academy Style Guide :
@app.template_filter("handlebars") def handlebars_filter(context, filepath): source = open( filepath, "r").read().decode('utf-8') template = pybars.Compiler().compile( source ) return Markup( u"".join( template( context )))
zedd45
source share