Insert javascript at top of including file in Jinja 2
问题 In Jinja2, I would like the following to work as it looks like it should, by running: from jinja2 import Environment, FileSystemLoader env = Environment(loader=FileSystemLoader('.')) template = env.get_template('x.html') print template.render() Essentially the objective is to coalesce all the javascript into the <head> tags by using a a {% call js() %} /* some js */ {% endcall %} macro. x.html <html> <head> <script type="text/javascript> {% block head_js %}{% endblock %} </script> </head>