0

I am building a section in which a client will list their various social network connections. There are fields for each social network's name and icon, as well as a field with the URL to the client's page on the specified network.

I also need a field that contains the code needed for each network's "Share" button. The code for "Share" buttons varies, but typically includes some HTML as well as <script> tags. When I output this field in a template, its contents are HTML encoded and displayed literally.

How can I keep this from being encoded so the HTML and Javascript can be parsed by the browser?

3

Giving the enduser the ability to include scripts is risky way to present social media links. Any errors could protentialy break the entire html page / site If you really want to do it this way you can use twig's raw filter

1
  • That works perfectly, thanks! Fortunately, in my case, there is only one "end user." I would never implement something like that on site where the content of that field couldn't be controlled. Oct 17 '16 at 18:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.