diff --git a/core/includes/theme.inc b/core/includes/theme.inc index e44f13d..390d5f0 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -20,7 +20,6 @@ use Drupal\Core\Page\LinkElement; use Drupal\Core\Page\MetaElement; use Drupal\Core\Template\Attribute; -use Drupal\Core\Template\RenderWrapper; use Drupal\Core\Theme\ThemeSettings; use Drupal\Component\Utility\NestedArray; use Drupal\Core\Render\Element; @@ -1972,7 +1971,7 @@ function template_preprocess_html(&$variables) { $variables['html_attributes'] = $page->getHtmlAttributes(); $variables['attributes'] = $page->getBodyAttributes(); - $variables['page'] = $page->getContent(); + $variables['page'] = $page; // Compile a list of classes that are going to be applied to the body element. // This allows advanced theming based on context (home page, node of certain type, etc.). @@ -2041,21 +2040,8 @@ function template_preprocess_html(&$variables) { $page->addMetaElement($metatag); } } - $variables['page_top'][] = array('#markup' => $page->getBodyTop()); $variables['page_bottom'][] = array('#markup' => $page->getBodyBottom()); - - // Add footer scripts as '#markup' so they can be rendered with other - // elements in page_bottom. - $footer_scripts = new RenderWrapper('drupal_get_js', array('footer')); - $variables['page_bottom'][] = array('#markup' => $footer_scripts); - - // Wrap function calls in an object so they can be called when printed. - $variables['head'] = new RenderWrapper(function() use ($page) { - return implode("\n", $page->getMetaElements()) . implode("\n", $page->getLinkElements()); - }); - $variables['styles'] = new RenderWrapper('drupal_get_css'); - $variables['scripts'] = new RenderWrapper('drupal_get_js'); } /** diff --git a/core/lib/Drupal/Core/Page/HtmlFragment.php b/core/lib/Drupal/Core/Page/HtmlFragment.php index 18f587a..99e0f7c 100644 --- a/core/lib/Drupal/Core/Page/HtmlFragment.php +++ b/core/lib/Drupal/Core/Page/HtmlFragment.php @@ -135,6 +135,40 @@ public function &getMetaElements() { } /** + * Implodes the meta and link elements for the template. + * + * @return + * A string of meta and link tags. + */ + public function getHead() { + return implode("\n", $this->getMetaElements()) . implode("\n", $this->getLinkElements()); + } + + /** + * Returns a themed presentation of all JavaScript code for the current page. + * + * @return + * All JavaScript code segments and includes for the scope as HTML tags. + * + * @see drupal_get_js() + */ + public function getScripts($scope = 'header') { + return drupal_get_js($scope); + } + + /** + * Returns a themed representation of all stylesheets to attach to the page. + * + * @return + * A string of XHTML CSS tags. + * + * @see drupal_get_css() + */ + public function getStyles() { + return drupal_get_css(); + } + + /** * Sets the response content. * * This should be the bulk of the page content, and will ultimately be placed diff --git a/core/lib/Drupal/Core/Template/RenderWrapper.php b/core/lib/Drupal/Core/Template/RenderWrapper.php deleted file mode 100644 index 7d7770d..0000000 --- a/core/lib/Drupal/Core/Template/RenderWrapper.php +++ /dev/null @@ -1,70 +0,0 @@ -callback = $callback; - $this->args = $args; - } - - /** - * Implements the magic __toString() method. - */ - public function __toString() { - return $this->render(); - } - - /** - * Returns a string provided by the callback function. - * - * @return string - * The results of the callback function. - */ - public function render() { - if (!empty($this->callback) && is_callable($this->callback)) { - return call_user_func_array($this->callback, $this->args); - } - } - -} diff --git a/core/modules/book/templates/book-export-html.html.twig b/core/modules/book/templates/book-export-html.html.twig index 0fc8b1d..cbeb3b3 100644 --- a/core/modules/book/templates/book-export-html.html.twig +++ b/core/modules/book/templates/book-export-html.html.twig @@ -22,7 +22,7 @@ {{ title }} - {{ head }} + {{ page.head }} diff --git a/core/modules/system/templates/html.html.twig b/core/modules/system/templates/html.html.twig index 209b914..d605532 100644 --- a/core/modules/system/templates/html.html.twig +++ b/core/modules/system/templates/html.html.twig @@ -29,17 +29,18 @@ - {{ head }} + {{ page.head }} {{ head_title }} - {{ styles }} - {{ scripts }} + {{ page.styles }} + {{ page.scripts }} {{ page_top }} - {{ page }} + {{ page.content }} {{ page_bottom }} + {{ page.scripts('footer') }} diff --git a/core/tests/Drupal/Tests/Core/Common/RenderWrapperTest.php b/core/tests/Drupal/Tests/Core/Common/RenderWrapperTest.php deleted file mode 100644 index 1a1b568..0000000 --- a/core/tests/Drupal/Tests/Core/Common/RenderWrapperTest.php +++ /dev/null @@ -1,59 +0,0 @@ - 'Render wrapper', - 'description' => 'Tests the RenderWrapper class used for late rendering.', - 'group' => 'Common', - ); - } - - /** - * Provides data for the RenderWrapper test. - * - * @return array - */ - public function providerTestRenderWrapperData() { - return array( - array('ucwords', array('Amazingly few discotheques provide jukeboxes.'), 'Amazingly Few Discotheques Provide Jukeboxes.', 'Simple string manipulation callback.'), - array('phpversion', array(), phpversion(), 'Callback with no arguments.'), - array(array('Drupal\Component\Utility\String', 'checkPlain'), array('