I've got a custom module in Drupal 8 that's putting out an XML feed. The structure of each item in the template that makes the feed looks like this:

<title><[[CDATA[{{ node.title|raw }}]]></title>
<category>{{ node.terms }}</category>
<description><[[CDATA[{{ node.body }}]]></description>

When I look at the feed, I see the CDATA enclosure on the title, but I don't see it on the description, just the text contents of the body.

Somehow, the site is searching for feeds that use the word "description", and then stripping the tags out of them, at the twig template level.

This is all very confusing for me, as this worked properly a week or two ago, and now CDATA has mysteriously vanished from all the feeds.

Here's been my debugging process so far: 1. Turned on Twig Debug mode, saw the correct template was loading, saw there was no field level template overriding the description portion. Also, in twig debug mode, the CDATA enclosure does appear normally, and vanishes again when I turn off debug mode. 2. If I change the enclosure name from description to "descriptiona" suddenly, the CDATA enclosure appears as normal 3. I made sure to clear the cache after each test and change. 4. Breaking the CDATA code by removing the closing > causes the rest of the characters in the CDATA enclosure to appear normally. 5. Adding

to the front and

to the back of the line in the feed template causes the


to also disappear along with the CDATA parts, which shows that I'm seeing an across the board twig-level strip tags effect of some kind. 6. I changed the theme of the site to see if a theme function was causing it, but I saw no change on the feeds. 7. I noticed it's not only the "description" enclosure that's flagged but also "media:description". Other variants of description seem unaffected. 8. I tried moving the CDATA code from the template into the data where I build the node.body string, but regardless the CATA portion was removed from the code on output. 9. I put a second CDATA wrapper around the first, this just resulted in an error. 10. I swapped the data part, so I had node.title output twice, just in case it was a content error. No effect other than now I had the title showing twice, once with CDATA in it's own correct title enclosure and one incorrect without CDATA in the description enclosure.

I'm a bit at my wits end with this. Any thoughts on how or where Drupal would even be re-writing portions of a Twig Template? I've looked through my custom modules over and over, and all I see is the manipulation of data. Nothing template overriding that I can tell. Definitely nothing that's targeting the word "description".

closed as off-topic by Kevin, leymannx, kiamlaluno Dec 8 '18 at 10:29

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question was caused by a problem that can no longer be reproduced, was solved by a cache clear, or was a simple typographical error. While similar questions may be on-topic here, this one was resolved in a manner unlikely to help future readers." – kiamlaluno
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    You have 3 open brackets and 2 closed. – dwcdev Dec 7 '18 at 11:24

Browse other questions tagged or ask your own question.