0

I'm trying to modularize my index.html file by having separate python files. Is there a way to convert say a Python string to HTML code? I know Flask uses Jinja templating and I've used it to extensively, but the kind of work I'm trying to do is as follows:

This is my HTML Code:

<article id="portfolios_RemoteSensing">
    <h2 style="text-align:center;"> Machine Learning and Remote Sensing</h2>
        <hr>
    <div style="text-align:left;">

    </div>
</article>

I want to encapsulate this as a python string then I'll jsut reference it through Jinja

x = "HTML CODE ABOVE"

{{ x }}

I hope this makes sense.

handavidbang
  • 593
  • 1
  • 6
  • 19

1 Answers1

2

Yes, pass x to your template and use {{ x|safe }}.

Also see this for some alternatives.

Till
  • 313
  • 2
  • 11