python 2.7 - How do I get html tags in variables to work? -


my code looks this

python:

render = web.template.render('templates/', base="layout") . . . fileout_text = codecs.open(filename_text, 'r', 'utf-8').read() text = markdown.markdown(fileout_text) return render.text_temple(text=text) 

text_template.html:

$def text      < text>$text < /text> 

now $text should contain html tags instead of markdown syntax.

my problem tags stay text when website displayed – why that?

your template system escaping html security measure. need tell template html output markdown "safe". based on code, i'm assuming using web.py. web.py docs state:

by default, templetor uses web.websafe filter html-encoding.

>>> render.hello("1 < 2") "hello 1 &lt; 2" 

to turnoff filter use : after $. example:

the following not html escaped. $:form.render() 

so in template try this:

$def text      < text>$:text < /text> 

adding colon ($:text) tell template system not escape html.

if guessed incorrectly , not using web.py, tell templating system using , perhaps can point right solution. although, know problem is, search docs templating system , find answer yourself.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -