When creating a custom node template (or any template) in Drupal 7 rendering a subset of content would mark it as 'printed' and therefor this subset/field wouldn't render twice. This seems to not be the case with Drupal 8. Is this as designed or is this a bug?

I've just created a node.html.twig file and I printed out my field followed by my main content:

...
{{content.field_name}}
...
{{content}}
...

the main {{content}} block still renders out {{content.field_name}}

I would have expected it to remove 'field_name' from the main content so its not rendered twice.

My workaround currently is to use 'without' on the main content block, which does the job, but as i said, is this as designed or a bug:

...
{{content.field_name}}
...
{{content|without('field_name')}}
...

Comments

ocastle’s picture

Title: Content subset renders twice » Content subset renders in main content block after already being rendered
star-szr’s picture

This is indeed as designed, and was the original reason for adding the |without filter (it now works for attributes as well). For most use cases we thought this way was more flexible and less of a head-scratcher than show/hide. The audience at DrupalCon Austin seemed to like it, anyway :) http://youtu.be/-Ksbm3w64nk?t=36m16s

https://www.drupal.org/node/2212845 is the change record for more information and I'm adding the issue where |without was added as a related issue.

ocastle’s picture

Great! Thanks for the reply. Will keep this in mind.