1

I am trying to send to my HTML template page some variables (to embed a plotly graph into a page). One of them will be the content a script tag and contains quotes. Once passed to the HTML pages these quotes are replaced by &#34 and the content doesn't display...

Here is the string variable that I want to give to my template :

script = window.PLOTLYENV=window.PLOTLYENV || {};window.PLOTLYENV.BASE_URL="https://plot.ly";Plotly.newPlot("abc0c362-7c6c-4b4e-b33f-62d174cf17a1", [{"type": "scatter", "x": [0, 1, 2, 3, 4], "y": [0, 1, 4, 9, 16]}], {}, {"showLink": true, "linkText": "Export to plot.ly"})

How I send data to my HTML template:

return render_template("image_display.html",Title="The Graph",div_id=id,script=script)

And the body of the HTML :

<body>
    <h1>{{Title}}</h1>
    <script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
    <div id="{{div_id}}" style="height: 100%; width: 100%;" class="plotly-graph-div"></div>
    <script type="text/javascript">{{script}}</script>
</body>

And the result :

enter image description here

Does anyone have a suggestion? Thanks a lot!

AlexM
  • 231
  • 2
  • 13

0 Answers0