When my Flask python script renders my template html ( render_template()
), my CSS doesn't render any changes to the html that I passed into the template using variables.
I know that was ridiculously wordy so reproducible code:
badcss = Markup('<span id="1">CSS DOES NOT RENDER</span>')
...
@app.route('/')
def front_page():
return render_template('/front.html', myhtml=badcss)
So if I have a CSS file linked in /front.html that references id 1:
#1 {
color: #FFFFFF;
}
The color of the text "CSS DOES NOT RENDER" will appear in the html of the template where I specified:
{{ myhtml }}
ends up being black, not white as specified by the CSS.
I have no idea why this is not rendering... Inspecting the #1 element, the CSS that explicitly references it is not computed, yet Markup does its job and renders the HTML and the CSS that is supposed to render with it as well, is visible in the CSS file.
My assumption is that the CSS renders before the HTML passed in as myhtml is rendered, but if this is the case I don't know how to work around this issue. Any advice/solutions would be welcome.