Page callback: Demonstrates a layout template.
string $key: The key of the page layout being requested.
array An array as expected by drupal_render().
function layout_page_view($key) {
  $layout = layout_manager()
    ->getDefinition($key);
  drupal_set_title(t('View template %name', array(
    '%name' => $layout['title'],
  )), PASS_THROUGH);
  // Render the layout in an admin context with region demonstrations.
  $instance = layout_manager()
    ->createInstance($key, array());
  $regions = $instance
    ->getRegions();
  foreach ($regions as $region => $info) {
    $regions[$region] = '<div class="layout-region-demonstration">' . check_plain($info['label']) . '</div>';
  }
  $build['demonstration'] = array(
    '#type' => 'markup',
    '#markup' => $instance
      ->renderLayout(TRUE, $regions),
  );
  $build['#attached']['css'][] = drupal_get_path('module', 'layout') . '/layout.admin.css';
  return $build;
}