It's generally a good idea to use render arrays rather than strings of HTML where possible -- they allow manipulation in alter hooks and the theme, and they mean that JS is better handled when content is cached.
However, theme_boxes_box() only allows the content of a box to be a string.
For the simple box type, this doesn't make much difference. But for more complex box plugins, this is an important feature.
This could be fairly easily changed in a way that is backwards-compatible:
- if $block['content'] is an array, treat it as a render array and return it wrapped with our prefix and suffix HTML.
- if $block['content'] is not an array, treat it as a string, and return a render array with that as #markup.
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | 2076815.boxes_.block-render-arrays.patch | 2.61 KB | joachim |
Comments
Comment #1
joachim commentedPatch is fairly simple, and backwards compatible with existing boxes plugins.
Comment #2
hefox commentedComment #4
hefox commentedBroke the tests so had to revert :/