Render arrays
Render arrays also existed in the previous versions of Drupal and they were important to the theme system. Since Drupal 8, however, they have become the thing—a core part of the Render API that is responsible for transforming markup representations into actual markup.
Acknowledging my limits as a writer, I will defer to the definition found in the Drupal.org documentation, which best describes what render arrays are:
... a hierarchical associative array containing data to be rendered and properties describing how the data should be rendered.
Simple, but powerful.
One of the principal reasons behind having render arrays is that they allow Drupal to delay the actual rendering of something into markup to the very last moment. What do I mean by this? For example, in Drupal 7, oftentimes as module developers we were calling the actual rendering service (the theme()
function) inside a preprocessor to "render" some data in order to print the resulting...