Your final example will work fine (but use <>code</> instead of (code) ). Jinja2, before the html is sent to the client, replaces the values inside double brackets. Jinja2 also doesn't care if you place template tags within script tags. React won't even see it. That said, your IDE will likely throw a fit (maybe not for this, but for anything more complex).
Your final example will work fine (but use
<>code</>
instead of(code)
). Jinja2, before the html is sent to the client, replaces the values inside double brackets. Jinja2 also doesn't care if you place template tags within script tags. React won't even see it. That said, your IDE will likely throw a fit (maybe not for this, but for anything more complex).However, there's another issue:
This adds CSS styling to your heading, but Jinja2 will try and interpret it, and cause an error, as it is not valid python.
This all said, I don't combining React and Jinja2 is something you would want to consider, even if it worked.