I have WYSWYG editor enabled on my fields when there is html in these fields. When I print out the variables in my template, the html gets converted to special characters.

for example my print statement

{{ node.field_hours.value }}

My full HTML in the field becomes this.

 <li>Camping : &lt;p&gt;&lt;strong&gt;Equestrian, Group and Primitive Sites:&lt;/strong&gt;&lt;/p&gt; <li>46 miles of marked multiuse trails.</li> <li>Florida law requires bicyclists under 16 to wear helmets.</li> </ul>

Bird Watching :


  • Site 64 on western section of


    3 Answers 3


    It is unsafe to print raw data from a field value.

    Instead of using {{ node.field_hours.value }} put this in your node template:

    {{ content.field_hours }}

    This will print out the field as configured in the view mode. In the view mode you can select a text filter that matches the allowed tags of the ckeditor. In Drupal 8 all necessary text formats are predefined to be used together with ckeditor.

    • Tried that though and it prints nothing
      – albo
      Mar 28, 2016 at 14:28

    It seems as if the <strong> tags are not allowed by your input formats.

    Go to /admin/config/content/formats, click on "Configure" for the text format you are using, make sure that the "Limit allowed HTML tags and correct faulty HTML" checkbox is checked.

    Once it's checked, make sure that under the tab with same name there is <strong> tag listed. If it's not there, just add it to the end of that field.

    For example:

    <a href hreflang> <li> <strong> # and so on

    Hope this helps.

    • it's actually all tags, it's converting all html to special characters this example just had <strong/>.
      – albo
      Mar 23, 2016 at 15:58
    • it was autoescaped so |raw filter worked twig.sensiolabs.org/doc/tags/autoescape.html
      – albo
      Mar 23, 2016 at 16:19
    • My bad - I misunderstood the initial question. I see that you updated the details and it makes more sense now. Check out the answer by 4k4, I believe that's the right one. Mar 23, 2016 at 20:34

    it was autoescaped so |raw filter worked http://twig.sensiolabs.org/doc/tags/autoescape.html

    Your Answer

    By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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