Hi all,
is it possible to mark some piece of data as safe to be rendered in a Zotonic template?
Similar to what safe
does in Django:
Cheers!
Hi all,
is it possible to mark some piece of data as safe to be rendered in a Zotonic template?
Similar to what safe
does in Django:
Cheers!
In Zotonic you can just echo any value as-is in the output.
We don’t apply escaping unless there is an escape
filter block around the values you are echoing.
We do this because all information stored in resources is already sanitized, and as such safe to echo in the output.
Ok, so is it possible to render html in a template from vars?
Something like:
z_template:render_to_iolist("zplay.tpl", #{v => "<p>Hello, zotonic!</p>"}, Context).
Can I render v
as html?
Cheers,
Carlo
Yes, no problem.
FYI… normally resource bodies are stored complete with markup… In that case, the body text will be pre-sanitized.
So I may be doing something wrong
Do I need something special template-side to render v
as html?
Because if I just use {{ v }}
I get the html entities encoded string (<p>Hello, zotonic!</p>
)
Cheers
v
needs to be a binary and everything works fine!
Thank you!
Cheers!
Carlo