Isaac Joy
Isaac Joy

Reputation: 95

Jinja template not rendering inline style correctly

I have an Python string that looks like this:

patternBackground = 'background-color:#1CA2FF; background-image:url("data:image/svg+xml, ...

that I'm trying to render in a Jinja template as an inline html style:

style="{{patternBackground}}"

The problem is that the style gets cut off by it's first quotation mark so all that renders is..

background-color:#1CA2FF; background-image:url(

Not rendering properly

enter image description here

I've tried to escape the quotation marks in the Python string, this still doesn't work.

Any ideas on how I can encode this or pass the style string through as one whole thing (that isn't prematurely cut off)

Appreciate any help!

Isaac

Upvotes: 0

Views: 598

Answers (1)

rgermain
rgermain

Reputation: 708

style="{{patternBackground|safe}}"

Upvotes: 1

Related Questions