Determine render support for Drupal Twig templates
Closed this issue · 1 comments
Currently, we don't really support Drupal's render
functionality at all. Drupal frequently passes around arrays that can be render
ed to strings, eg this template, where the content
variable could be an array of fields:
<span{{ attributes }}>{{ content }}</span>
We definitely can't support the full render API - that would require bootstrapping Drupal and knowing about all of the various element types and theme hooks that are implemented by the modules you have enabled. But I think there is a way we could make the render
concept useful in Mannequin. Eg:
{# @Component
name: Some Template
samples:
Has Field Data:
content:
field_image: ~markup('<img src="..." />
body: ~markup('<p>I wish I was in dixie...</p>')
#}
<span{{ attributes }}>{{ content }}</span>
So my proposal here is that we implement some very basic support for concatenating nested arrays of strings. This would allow all of the following, given the above metadata:
<span{{ attributes }}>{{ content }}</span>
<span{{ attributes }}>{{ content|render }}</span>
<span{{ attributes }}>{{ content.field_image }}{{ content|without('field_image')|render }}</span>
This seems like a good start, and would allow a lot of the common functionality of the render system to be mocked in Mannequin. At this point I'm looking for objections or comments on the concept. I'm hoping to implement this in 1.0.6.