I have no idea how, but would like to know if it is possible to change the file in the jinja2 include statement.
such as:
{% include file.name %} to {% include file1.name %}
Since the file.name is in include parentheses, I could not use {{ file.name }} to achieve this.
Thought maybe I could use something like jquery,
$(".btnt").click(function(){
$("section:fourth").replaceWith("{% include 'file1.name' %}");}
maybe initiate with button click, would this have to be on same page. I tend to use flask python for most projects.
2
Answers
Actually used jinja2 to read variable to decide which file.name to use
This checks var for true, set from flask render template arguments. If true uses file.name, if false uses file1.name
Hey there is a technique which i use to transfer server side rendering to client side. it is basically returing json to the template itself directly. Like this:
app.py
a.html
This code should help you to use jinja in your scripts. But I recommend you to use APIs that return json data instead of this. For that you can use
$.getJSON
method.