Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

8
  • Cool, I didn't know you could do stuff like this on twig. I'm gonna go with @Japan's answer just because it's a little more bullet proof since someone else is going to be doing the theming. I know I am splitting hairs here. Commented Jun 19, 2017 at 8:20
  • You can build the render element in php as well, but you really should use the render element, see the documentation. Commented Jun 19, 2017 at 8:22
  • you really should use the render element fantabulous, one slight problem, my actual scenario #test is an array of node objects (didn't mention this in the Q to keep it simple). Not sure how I am going to make the twig looping work with the Render element in php approach. Might not be possible. Commented Jun 19, 2017 at 8:59
  • 1
    Yes, put an array in #test with multiple processed_text render elements, all array keys that don't start with a '#' will be considered as render children, also the numbers of an indexed array. You don't need a loop, twig renders all render children it finds in {{ test }} automatically. Commented Jun 19, 2017 at 9:08
  • 1
    btw. you need to add cache tags from the nodes to the render array if you want that this gets invalidated when a node is modified, or create a view mode for the content type to output the body fields, this is best for caching and performance Commented Jun 19, 2017 at 9:20