In my Jinja template for Flask application I have this snippet:
{% elif mydata.accepted==True %}
{% set accept_off = 'Yes' %}
{{accept_off}}
{% else %}
It sets value and renders in the html. Works fine.
Javascript snippet:
<script>
$(document).ready(function () {
console.log( "ready!" );
alert('{{ accept_off}}'); // comes empty, though rendered in template
alert('{{ datafromserver}})'; // works fine
var item = ('{{set accept_off = yes}}');
alert(item); // works as well
...
This snippet alerts empty "accept_off" variable though in template it renders fine. And second alert with data from server passed during rendering it works fine as well.
So how does it work that I cannot set variable in Jinja template and then use it in javadcript?