OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Jinja templating in JavaScript

  • Thread starter Thread starter PythonicOreo
  • Start date Start date
P

PythonicOreo

Guest
I am using Flask, and I am trying to send data to my HTML page. The obvious choice is Jinja templating: {{ input_msg }}, but the problem is that I am inside curly brackets already, since I need to put the variable into JavaScript:

Code:
request.onload = function() {
if (request.status === 200 && request.responseText === 'done') {
    window.location = {{ inp_msg }};
}
};

The above will not work because curly brackets are being used for templating, but inside JavaScript as well. Is there another way to send data, not Jinja? If not, is there another Jinja way?

<p>I am using Flask, and I am trying to send data to my HTML page. The obvious choice is Jinja templating: <code>{{ input_msg }}</code>, but the problem is that I am inside curly brackets already, since I need to put the variable into JavaScript:</p>
<pre class="lang-js prettyprint-override"><code>request.onload = function() {
if (request.status === 200 && request.responseText === 'done') {
window.location = {{ inp_msg }};
}
};
</code></pre>
<p>The above will not work because curly brackets are being used for templating, but inside JavaScript as well. Is there another way to send data, not Jinja? If not, is there another Jinja way?</p>
 

Latest posts

Top