Render API

Benjamin Melançon's picture

Renderable arrays versus strings

Tags

  • Render API
  • Book element

  • Gotcha
  • Drupal 7 would like you to provide all content meant for display to the user as renderable arrays (which allows changes from other parts of Drupal and potentially smart caching). It does, however, accept a plain string, and outputs that directly, and indeed Drupal core often does this.

    To mix simple strings with proper render arrays, simply use '#markup' => $raw_html; for your string

    (thanks to davereid and chx in IRC for pointing this out)

  • Explanation

  • module dev chapter
  • Subscribe to Render API