commit 7b921de2c2b71387b3734de901856ff226ef3668 Author: Joel Pittet Date: Mon May 27 20:50:17 2013 -0700 move contact to array diff --git a/core/includes/theme.inc b/core/includes/theme.inc index ada8d79..d89247e 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -12,9 +12,9 @@ use Drupal\Core\Config\Config; use Drupal\Core\Language\Language; use Drupal\Core\Template\Attribute; +use Drupal\Core\Template\RenderableWrapper; use Drupal\Core\Utility\ThemeRegistry; use Drupal\Core\Theme\ThemeSettings; -use Drupal\Core\Template\RenderableWrapper; /** * @defgroup content_flags Content markers @@ -2855,19 +2855,21 @@ function template_preprocess_html(&$variables) { // Previous process layer. drupal_add_library('system', 'html5shiv', TRUE); // Render page_top and page_bottom into top level variables. - $variables['page_top'] = isset($variables['page']['page_top']) ? drupal_render($variables['page']['page_top']) : ''; - $variables['page_bottom'] = isset($variables['page']['page_bottom']) ? drupal_render($variables['page']['page_bottom']) : ''; + $variables['page_top'] = isset($variables['page']['page_top']) ? $variables['page']['page_top'] : array(); + $variables['page_bottom'] = array(); + $variables['page_bottom'][] = isset($variables['page']['page_bottom']) ? $variables['page']['page_bottom'] : array(); // Place the rendered HTML for the page body into a top level variable. $variables['page'] = $variables['page']['#children']; - - $variables['head'] = drupal_get_html_head(); $variables['css'] = drupal_add_css(); // Replaced drupal_get_css() and drupal_get_js() so they return an object // that can render itself on print. + $variables['head'] = new RenderableWrapper('drupal_get_html_head'); $variables['styles'] = new RenderableWrapper('drupal_get_css'); $variables['scripts'] = new RenderableWrapper('drupal_get_js'); - $variables['page_bottom'] = new RenderableWrapper('drupal_get_js', $args = array('footer')); + + $footer_scripts = new RenderableWrapper('drupal_get_js', array('footer')); + $variables['page_bottom'][] = array('#markup' => $footer_scripts); } /** diff --git a/core/lib/Drupal/Core/Template/RenderableWrapper.php b/core/lib/Drupal/Core/Template/RenderableWrapper.php index f7b2bb6..200d16b 100644 --- a/core/lib/Drupal/Core/Template/RenderableWrapper.php +++ b/core/lib/Drupal/Core/Template/RenderableWrapper.php @@ -9,11 +9,37 @@ /** - * Renderable wrapper for drupal_get_js(), drupal_get_css(), drupal_get_head(), - * etc. + * Renderable wrapper for drupal_get_* functions. + */ + + +/** + * A class that wraps drupal_get_* functions so they can be rendered in a template. + * + * To use, one may pass in the function name as a string followed by an array of + * arguments to the contstructor. + * @code + * $variables['scripts'] = new RenderableWrapper('drupal_get_js'); + * {{ scripts }}; + * // Produces + * + * @endcode + * */ class RenderableWrapper { + + /** + * Stores the callback function to be called when rendered. + * + * @var array + */ public $callback = NULL; + + /** + * Stores the callback's arguments. + * + * @var array + */ public $args = array(); /** @@ -41,9 +67,6 @@ public function __toString() { /** * Call the callback function. * - * Does this make exceptions not work... change to render() and let twig - * call that. - * * @return string the results of the drupal_get_* functions. */ public function render() {