Craft CMS Stack Exchange is a question and answer site for administrators, end users, developers and designers for Craft CMS. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a field in a matrix block that is used for video embed codes. I want to output the contents of that field directly as HTML. However, it always seems to get entity-encoded (ie. the < and > get converted to &lt; and &gt;), so the html just appears as text.

I know about Twig's |raw filter, so I tried outputting the field's content through it (eg. using {{ element.blockContent|raw }}), but it seems to make no difference. Can anyone tell me what I'm doing wrong?

(Just in case it's relevant, this is a sub-template that is being included in a for loop that goes through the matrix blocks and outputs them)

share|improve this question

The difference between "raw" and "escape" is sometimes confusing... Try this instead:

{{ element.blockContent|e }}


The escape filter escapes a string for safe insertion into the final output.


The raw filter marks the value as being "safe", which means that in an environment with automatic escaping enabled this variable will not be escaped if raw is the last filter applied to it.

share|improve this answer
Thanks for this. It turned out the problem for me was actually something else (see below), but this is still useful to know. – Nick F Aug 5 '14 at 17:46
up vote 4 down vote accepted

For what it's worth, the problem was due to a mistake on my part: the field in question had been set up as Rich Text, and then switched to Plain Text. I guess the original HTML had been encoded going into the database when the field was still Rich Text, and so was already entity-encoded before it even reached the template. When I pasted the HTML in question back in and saved the post again all was well.

So for me, the solution was: make sure that the HTML was definitely saved as raw HTML in a Plain Text field.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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