Python Forum
[Solved] Browser won't parse text from yaml loaded into Jinja
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Solved] Browser won't parse text from yaml loaded into Jinja
#1
Hi everyone,

I'm loading a yaml file into Flask with

with open('myfile.yml', 'r') as file:
    TheYaml = yaml.safe_load(file)
In my .html template I'm loading what I need from this yaml like this with Jinja

{{ [TheYaml["akey"] }}
The value of this key is loaded in the html but any HTML tag for exemple <br> is not parsed by the browser !
I know about the Jinja escaping (I've try everything) but I think the problem lay somewhere else..

It's weird as in the Browser developer tools, this text if fully grey-out (even the html tags... )

Any ideas ?

Edit:

I've run
type([TheYaml["akey"])
Output:
<class 'str'>
so everything look ok.. Wall

edit2:
I've try without yaml

like this
return render_template('content.html', testing={"a_test": "let <b>try</b> it"})
I have the same problem.. the <b> and </b> are not parsed. so the problem si not the yaml.. but the Jinja/ Flask ??
[Image: NfRQr9R.jpg]
Reply
#2
Don't bother I solved it !
I will write the solution later on...
[Image: NfRQr9R.jpg]
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Unable to convert browser generated xml to parse in BeautifulSoup Nik1811 0 286 Mar-22-2024, 01:37 PM
Last Post: Nik1811
Question Accessing a value of a dictionary with jinja.... SpongeB0B 2 10,554 Aug-06-2021, 09:05 AM
Last Post: ndc85430
  Jinja sort values from request.form SpongeB0B 2 2,240 Jul-26-2020, 07:41 AM
Last Post: SpongeB0B
  how to create dynamic arguments to be passed in jinja template in url_for function? experimental 1 2,790 May-01-2020, 05:50 PM
Last Post: Larz60+
  Flask tutorial errors in jinja, auth undefined Ecniv 2 2,529 May-03-2019, 02:04 PM
Last Post: Ecniv
  webdriver.remote to connect back existing browser without open new browser? gahhon 6 6,788 Feb-26-2019, 03:53 PM
Last Post: gahhon
  flask sqlite jinja accessing and updating database help pascale 5 4,185 Feb-11-2019, 03:49 PM
Last Post: pascale
  flask: instance config not loaded wardancer84 3 3,190 Jan-29-2019, 11:51 AM
Last Post: wardancer84
  display multiple sensors on webpage python flask jinja pascale 6 5,279 Jan-29-2019, 10:10 AM
Last Post: pascale

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020