Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Template Questions /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Is there a way to stop Silverstripe to encode my HTML?


Go to End


3 Posts   1962 Views

Avatar
mi32dogs

Community Member, 75 Posts

28 April 2015 at 11:12am

Hi, Quick question, it is maybe answered before but I can’t find it.

In the template for a gallery I need to put some HTML in a data tag like so

<div data-src="/assets/photo/myphoto.jpg" data-sub-html="<h3>My caption</h3><p>My description.</p>">photo</div>

But it renders it like this

<div data-src="/assets/photo/myphoto.jpg" data-sub-html="&lt;h3&gt;My caption&lt;/h3&gt;&lt;p&gt;My description..&lt;/p&gt;">photo</div>

Is there a way to stop Silverstripe to encode my HTML?

Avatar
Pyromanik

Community Member, 419 Posts

11 May 2015 at 10:52pm

That is correct to the standard. It should be encoded, otherwise your HTML is not valid. If the gallery javascript doesn't work with that output, then I would highly recommend finding a better gallery plugin (one that doesn't require you to invalidate your HTML get it to work).

But to answer the question, $Output.RAW should suffice.

Avatar
mi32dogs

Community Member, 75 Posts

12 May 2015 at 4:07pm

Thank you Pyromanik