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.

Comments

joachim’s picture

Status: Active » Needs review
StatusFileSize
new2.61 KB

Patch is fairly simple, and backwards compatible with existing boxes plugins.

hefox’s picture

Issue summary: View changes
Status: Needs review » Fixed

  • hefox committed ea41bff on 7.x-1.x authored by joachim
    Issue #2076815 by joachim: Allow blocks to return render arrays
    
hefox’s picture

Priority: Major » Normal
Status: Fixed » Needs work

Broke the tests so had to revert :/

  • hefox committed 9ce35b7 on 7.x-1.x
    Revert "Issue #2076815 by joachim: Allow blocks to return render arrays...