DEV Community

[Comment from a deleted post]
Collapse
 
hamishwhc profile image
HamishWHC • Edited

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:

return <>
  <h1 style={{fontFamily: "Courier New"}}></h1>
</>
Enter fullscreen mode Exit fullscreen mode

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.