Is there a component for HTML content?

18 views
Skip to first unread message

Antonio Sala

unread,
Jul 4, 2014, 9:44:37 AM7/4/14
to mont...@googlegroups.com
Hi all, 
is there any component that can be used to display HTML content? I tried to put html obtained from a REST web service into a text component but the html is not rendered but displayed as it is. Is there any way to do this so that the HTML content received by the service can be properly displayed?

Thanks in advance for any help you could provide.

António Afonso

unread,
Jul 4, 2014, 12:47:55 PM7/4/14
to mont...@googlegroups.com
Hi Antonio,

You can use the DynamicElement component that is available on the "matte" package. Here's an example of its usage: http://montagejs.github.io/mfiddle/#!/aa99035bdaae0e77351b

You use the "innerHTML" property of the component just like you would do with an HTML element.

Given the security problems of dumping HTML into a page (http://en.wikipedia.org/wiki/Cross-site_scripting) the component only allows HTML elements that are explicitly specified in the "allowedTagNames" property.

Hope it helps!

Antonio Sala

unread,
Jul 4, 2014, 12:53:01 PM7/4/14
to mont...@googlegroups.com
Thanks, that looks exactly what I was looking for!
Reply all
Reply to author
Forward
0 new messages