diff --git a/core/includes/theme.inc b/core/includes/theme.inc index cfd8427..9160b09 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -1912,7 +1912,7 @@ function _template_preprocess_default_variables() { * * @see system_element_info() */ -function drupal_pre_render_html(array $element) { +function drupal_pre_render_page(array $element) { // Add favicon. if (theme_get_setting('features.favicon')) { $favicon = theme_get_setting('favicon.url'); @@ -1927,23 +1927,28 @@ function drupal_pre_render_html(array $element) { return $element; } /** - * Prepares variables for HTML document templates. + * Prepares variables for HTML page templates. * - * Default template: html.html.twig. + * Default template: page.html.twig. * - * @param array $variables - * An associative array containing: - * - page: A render element representing the page. + * Most themes utilize their own copy of page.html.twig. The default is located + * inside "modules/system/page.html.twig". Look in there for the full list of + * variables. + * + * Uses the arg() function to generate a series of page template suggestions + * based on the current path. + * + * Any changes to variables in this preprocessor should also be changed inside + * template_preprocess_maintenance_page() to keep all of them consistent. * - * @see system_elements() + * @see drupal_render_page() */ -function template_preprocess_html(&$variables) { +function template_preprocess_page(&$variables) { /** @var $page \Drupal\Core\Page\HtmlPage */ - $page = $variables['page_object']; + $page = $variables['page']['#page']; $variables['html_attributes'] = $page->getHtmlAttributes(); $variables['attributes'] = $page->getBodyAttributes(); - $variables['page'] = $page->getContent(); // 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.). @@ -2001,7 +2006,7 @@ function template_preprocess_html(&$variables) { $variables['head_title_array'] = $head_title; $variables['head_title'] = implode(' | ', $head_title); - // Display the html.html.twig's default mobile metatags for responsive design. + // Display the page.html.twig's default mobile metatags for responsive design. $elements = array( 'MobileOptimized' => array( '#tag' => 'meta', @@ -2041,25 +2046,6 @@ function template_preprocess_html(&$variables) { $variables['head'] = new RenderWrapper('drupal_get_html_head'); $variables['styles'] = new RenderWrapper('drupal_get_css'); $variables['scripts'] = new RenderWrapper('drupal_get_js'); -} - -/** - * Prepares variables for the page template. - * - * Default template: page.html.twig. - * - * Most themes utilize their own copy of page.html.twig. The default is located - * inside "modules/system/page.html.twig". Look in there for the full list of - * variables. - * - * Uses the arg() function to generate a series of page template suggestions - * based on the current path. - * - * @see drupal_render_page() - */ -function template_preprocess_page(&$variables) { - $language_interface = \Drupal::languageManager()->getCurrentLanguage(); - $site_config = \Drupal::config('system.site'); // Move some variables to the top level for themer convenience and template cleanliness. $variables['show_messages'] = $variables['page']['#show_messages']; @@ -2395,10 +2381,6 @@ function template_preprocess_region(&$variables) { function drupal_common_theme() { return array( // From theme.inc. - 'html' => array( - 'variables' => array('page_object' => NULL), - 'template' => 'html', - ), 'page' => array( 'render element' => 'page', 'template' => 'page', diff --git a/core/lib/Drupal/Core/Ajax/AjaxResponse.php b/core/lib/Drupal/Core/Ajax/AjaxResponse.php index 6678e7a..cb3184e 100644 --- a/core/lib/Drupal/Core/Ajax/AjaxResponse.php +++ b/core/lib/Drupal/Core/Ajax/AjaxResponse.php @@ -88,7 +88,7 @@ public function prepareResponse(Request $request) { * An array of commands ready to be returned as JSON. */ protected function ajaxRender(Request $request) { - // Ajax responses aren't rendered with html.html.twig, so we have to call + // Ajax responses aren't rendered with page.html.twig, so we have to call // drupal_get_css() and drupal_get_js() here, in order to have new files // added during this request to be loaded by the page. We only want to send // back files that the page hasn't already loaded, so we implement simple diff --git a/core/lib/Drupal/Core/Page/DefaultHtmlPageRenderer.php b/core/lib/Drupal/Core/Page/DefaultHtmlPageRenderer.php index 821d42d..579201d 100644 --- a/core/lib/Drupal/Core/Page/DefaultHtmlPageRenderer.php +++ b/core/lib/Drupal/Core/Page/DefaultHtmlPageRenderer.php @@ -16,11 +16,7 @@ class DefaultHtmlPageRenderer implements HtmlPageRendererInterface { * {@inheritdoc} */ public function render(HtmlPage $page) { - $render = array( - '#type' => 'html', - '#page_object' => $page, - ); - return drupal_render($render); + return $page->getContent(); } } diff --git a/core/modules/book/book.module b/core/modules/book/book.module index 48c81d5..e3ce5e2 100644 --- a/core/modules/book/book.module +++ b/core/modules/book/book.module @@ -676,7 +676,7 @@ function template_preprocess_book_navigation(&$variables) { /** * Prepares variables for book export templates. * - * Default template: book-export-html.html.twig. + * Default template: book-export-page.html.twig. * * @param array $variables * An associative array containing: @@ -704,7 +704,7 @@ function template_preprocess_book_export_html(&$variables) { /** * Prepares variables for single node export templates. * - * Default template: book-node-export-html.html.twig. + * Default template: book-node-export-page.html.twig. * * @param array $variables * An associative array containing the following keys: diff --git a/core/modules/book/templates/book-export-html.html.twig b/core/modules/book/templates/book-export-html.html.twig index 0fc8b1d..1bd9a3c 100644 --- a/core/modules/book/templates/book-export-html.html.twig +++ b/core/modules/book/templates/book-export-html.html.twig @@ -11,9 +11,9 @@ * right to left language. * - base_url: URL to the home page. * - contents: Nodes within the current outline rendered through - * book-node-export-html.html.twig. + * book-node-export-page.html.twig. * - * @see template_preprocess_book_export_html() + * @see template_preprocess_book_export_page() * * @ingroup themeable */ diff --git a/core/modules/node/node.module b/core/modules/node/node.module index c97851e..ea1fdb6 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -594,7 +594,7 @@ function node_is_page(NodeInterface $node) { /** * Implements hook_preprocess_HOOK() for HTML document templates. */ -function node_preprocess_html(&$variables) { +function node_preprocess_page(&$variables) { // If on an individual node page, add the node type to body classes. if (($node = \Drupal::request()->attributes->get('node')) && $node instanceof NodeInterface) { $variables['attributes']['class'][] = drupal_html_class('node-type-' . $node->getType()); diff --git a/core/modules/rdf/rdf.module b/core/modules/rdf/rdf.module index f925304..7e34b91 100644 --- a/core/modules/rdf/rdf.module +++ b/core/modules/rdf/rdf.module @@ -256,7 +256,7 @@ function rdf_theme() { /** * Implements hook_preprocess_HOOK() for HTML document templates. */ -function rdf_preprocess_html(&$variables) { +function rdf_preprocess_page(&$variables) { // Adds RDF namespace prefix bindings in the form of an RDFa 1.1 prefix // attribute inside the html element. if (!isset($variables['html_attributes']['prefix'])) { diff --git a/core/modules/system/lib/Drupal/system/Tests/Theme/ThemeTest.php b/core/modules/system/lib/Drupal/system/Tests/Theme/ThemeTest.php index 638d8e5..1c1b9d0 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Theme/ThemeTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Theme/ThemeTest.php @@ -275,7 +275,7 @@ public function testFindThemeTemplates() { function testPreprocessHtml() { $this->drupalGet(''); $attributes = $this->xpath('/html/body[@theme_test_page_variable="Page variable is an array."]'); - $this->assertTrue(count($attributes) == 1, 'In template_preprocess_html(), the page variable is still an array (not rendered yet).'); + $this->assertTrue(count($attributes) == 1, 'In template_preprocess_page(), the page variable is still an array (not rendered yet).'); $this->assertText('theme test page bottom markup', 'Modules are able to set the page bottom region.'); } diff --git a/core/modules/system/system.module b/core/modules/system/system.module index 65a8796..f1082f2 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -278,14 +278,6 @@ function system_hook_info() { */ function system_element_info() { // Top level elements. - $types['html'] = array( - '#theme' => 'html', - '#pre_render' => array('drupal_pre_render_html'), - // HTML5 Shiv - '#attached' => array( - 'library' => array('core/html5shiv'), - ), - ); $types['form'] = array( '#method' => 'post', '#action' => request_uri(), @@ -295,6 +287,11 @@ function system_element_info() { '#show_messages' => TRUE, '#theme' => 'page', '#title' => '', + '#pre_render' => array('drupal_pre_render_page'), + // HTML5 Shiv + '#attached' => array( + 'library' => array('core/html5shiv'), + ), ); // By default, we don't want Ajax commands being rendered in the context of an // HTML page, so we don't provide defaults for #theme or #theme_wrappers. diff --git a/core/modules/system/templates/html.html.twig b/core/modules/system/templates/html.html.twig deleted file mode 100644 index 209b914..0000000 --- a/core/modules/system/templates/html.html.twig +++ /dev/null @@ -1,45 +0,0 @@ -{# -/** - * @file - * Default theme implementation for the basic structure of a single Drupal page. - * - * Variables: - * - css: A list of CSS files for the current page. - * - head: Markup for the HEAD element (including meta tags, keyword tags, and - * so on). - * - head_title: A modified version of the page title, for use in the TITLE tag. - * - head_title_array: List of text elements that make up the head_title - * variable. May contain or more of the following: - * - title: The title of the page. - * - name: The name of the site. - * - slogan: The slogan of the site. - * - page_top: Initial rendered markup. This should be printed before 'page'. - * - page: The rendered page markup. - * - page_bottom: Closing rendered markup. This variable should be printed after - * 'page'. - * - styles: Style tags necessary to import all necessary CSS files in the head. - * - scripts: Script tags necessary to load the JavaScript files and settings - * in the head. - * - * @see template_preprocess_html() - * - * @ingroup themeable - */ -#} - - -
- {{ head }} -