How do I render html content inside a template block

23 views
Skip to first unread message

tanmay datta

unread,
Oct 28, 2016, 11:19:21 PM10/28/16
to ChicagoBoss
Say my page template has 
<div>{{ html_block }}</div>


My controller is passing this html block as:
Test = "<h1> Checking html rendering </h1>", 
 {ok, [{page, Page_ID}, {html_block, Test}]}



The final outcome is 

So how do I make it displayed as a header ? 
 

Graeme Defty

unread,
Oct 29, 2016, 12:17:39 AM10/29/16
to chica...@googlegroups.com
From http://chicagoboss.org/doc/api-view.html ...

Configuring ErlyDTL

By default, ErlyDTL escapes HTML in values that are passed in template variables. This behaviour is configurable in CB, by setting the value of template_auto_escape to either true or false in boss.config.


... so it seems that CB allows you to suppress escaping only at the application level, which may be OK but typically not what you would want.

I am not sure whether maybe you could side-step escaping by writing your own custom tab?

Alternatively, Django (on which ERLydtl is based) has a tag to switch autoescape on and off (see https://django.readthedocs.io/en/1.6.x/ref/templates/builtins.html) but I have never tried it in CB.

Good luck!

Graeme






--
You received this message because you are subscribed to the Google Groups "ChicagoBoss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chicagoboss+unsubscribe@googlegroups.com.
Visit this group at https://groups.google.com/group/chicagoboss.
To view this discussion on the web visit https://groups.google.com/d/msgid/chicagoboss/66c010e2-96a1-4ec7-a1dc-2bbdf17c32da%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Phang Mulianto

unread,
Oct 29, 2016, 1:29:32 AM10/29/16
to ChicagoBoss
HI,

Django template have |escape filter to show html content from the view , i not sure in EarlyDTL. it is a safe mechanism for protect html injection / javascript injection on template from outside.

why not put <div><h1>{{ html_block }}</h1></div>   in your template.


Regards,

Mulianto

tanmay datta

unread,
Oct 30, 2016, 12:26:27 AM10/30/16
to ChicagoBoss
Reason behind that was my workflow. 
I normally write whatever I learn on emacs org mode, from which I can generate html pages. 
I automated the process of publishing just the <body> content to the static directory and I wanted to server them as pages in my blog (while extending the "base" template). 
Nevermind I have found the solution. I need to use filter "safe" in the template.

Thanks for your help guys!!   
Reply all
Reply to author
Forward
0 new messages