Loading external script with jinja2 template directive

前端 未结 2 1053
梦如初夏
梦如初夏 2020-12-04 19:44

I\'m very new to jinja2 and the use of templates in general so I was wondering if there\'s an easy way to load an external javascript. I was thinking of using:



        
2条回答
  •  执笔经年
    2020-12-04 20:35

    This question is quite old, but there is another way of doing it that might be interesting as well. I found it while working with Jinja2 and flask.

    I used the url_for() and it works fine:

    {% block javascript %}
        
    {% endblock %}
    

    And I have my myscript.js in my static folder. Specified in Jinja2 environment, or by default in flask.

提交回复
热议问题