diff --git a/core/includes/theme.inc b/core/includes/theme.inc index 1526113..cab2d1a 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -1972,23 +1972,29 @@ function _template_preprocess_default_variables() { } /** - * 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. * - * @see system_elements() + * Any changes to variables in this preprocessor should also be changed inside + * template_preprocess_maintenance_page() to keep all of them consistent. + * + * @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(); + $variables['page']['content'] = $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.). @@ -2064,7 +2070,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', @@ -2106,26 +2112,7 @@ 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. - * - * Any changes to variables in this preprocessor should also be changed inside - * template_preprocess_maintenance_page() to keep all of them consistent. - * - * @see drupal_render_page() - */ -function template_preprocess_page(&$variables) { $language_interface = \Drupal::languageManager()->getCurrentLanguage(); $site_config = \Drupal::config('system.site'); @@ -2480,10 +2467,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 63e0d9c..3f1127d 100644 --- a/core/lib/Drupal/Core/Page/DefaultHtmlPageRenderer.php +++ b/core/lib/Drupal/Core/Page/DefaultHtmlPageRenderer.php @@ -17,8 +17,8 @@ class DefaultHtmlPageRenderer implements HtmlPageRendererInterface { */ public function render(HtmlPage $page) { $render = array( - '#theme' => 'html', - '#page_object' => $page, + '#type' => 'page', + '#page' => $page, ); return drupal_render($render); } 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 74dc548..2607627 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/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 }} - {{ head_title }} - {{ styles }} - {{ scripts }} - - - - {{ page_top }} - {{ page }} - {{ page_bottom }} - - diff --git a/core/modules/system/templates/install-page.html.twig b/core/modules/system/templates/install-page.html.twig index a462a5a..b97538f 100644 --- a/core/modules/system/templates/install-page.html.twig +++ b/core/modules/system/templates/install-page.html.twig @@ -3,8 +3,8 @@ * @file * Default theme implementation to display a Drupal installation page. * - * All the available variables are mirrored in html.html.twig and - * page.html.twig. Some may be blank but they are provided for consistency. + * All the available variables are page.html.twig. + * Some may be blank but they are provided for consistency. * * @see template_preprocess_install_page() * diff --git a/core/modules/system/templates/maintenance-page.html.twig b/core/modules/system/templates/maintenance-page.html.twig index b71fa24..2fca2d0 100644 --- a/core/modules/system/templates/maintenance-page.html.twig +++ b/core/modules/system/templates/maintenance-page.html.twig @@ -3,8 +3,7 @@ * @file * Default theme implementation to display a single Drupal page while offline. * - * All the available variables are mirrored in html.html.twig and - * page.html.twig. + * All the available variables are mirrored in page.html.twig. * Some may be blank but they are provided for consistency. * * @see template_preprocess_maintenance_page() diff --git a/core/modules/system/templates/page.html.twig b/core/modules/system/templates/page.html.twig index 1f6f916..3eb027c 100644 --- a/core/modules/system/templates/page.html.twig +++ b/core/modules/system/templates/page.html.twig @@ -3,9 +3,6 @@ * @file * Default theme implementation to display a single page. * - * The doctype, html, head and body tags are not in this template. Instead they - * can be found in the html.html.twig template in this directory. - * * Available variables: * * General utility variables: @@ -15,6 +12,20 @@ * - logged_in: A flag indicating if the user is registered and signed in. * - is_admin: A flag indicating if the user has permission to access * administration pages. + * - 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. + * - page_bottom: Closing rendered markup. + * - 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. * * Site identity: * - front_page: The URL of the front page. Use this instead of base_path when @@ -58,97 +69,112 @@ * - page.footer: Items for the footer region. * * @see template_preprocess_page() - * @see html.html.twig * * @ingroup themeable */ #} -
- -
- {% if logo %} - - {{ 'Home'|t }} - - {% endif %} - - {% if site_name or site_slogan %} -
- - {# Use h1 when the content title is empty #} - {% if title %} - - {{ site_name }} - - {% else %} -

- {{ site_name }} -

- {% endif %} - - {% if site_slogan %} -
{{ site_slogan }}
+ + + + {{ head }} + {{ head_title }} + {{ styles }} + {{ scripts }} + + + + {{ page_top }} +
+ +
+ {% if logo %} + + {{ 'Home'|t }} + {% endif %} -
{# ./name-and-slogan #} - {% endif %} - {{ page.header }} -
- - {% if main_menu or secondary_menu %} - - {% endif %} + {% if site_name or site_slogan %} +
+ + {# Use h1 when the content title is empty #} + {% if title %} + + {{ site_name }} + + {% else %} +

+ {{ site_name }} +

+ {% endif %} + + {% if site_slogan %} +
{{ site_slogan }}
+ {% endif %} +
{# ./name-and-slogan #} + {% endif %} + + {{ page.header }} + + + {% if main_menu or secondary_menu %} + + {% endif %} - {{ breadcrumb }} + {{ breadcrumb }} - {{ messages }} + {{ messages }} - {{ page.help }} + {{ page.help }} -
- {# link is in html.html.twig #} +
+ {# link is in page.html.twig #} -
- {{ page.highlighted }} +
+ {{ page.highlighted }} - {{ title_prefix }} - {% if title %} -

{{ title }}

- {% endif %} - {{ title_suffix }} + {{ title_prefix }} + {% if title %} +

{{ title }}

+ {% endif %} + {{ title_suffix }} - {{ tabs }} + {{ tabs }} - {% if action_links %} - - {% endif %} + {% if action_links %} + + {% endif %} - {{ page.content }} + {{ page.content }} - {{ feed_icons }} -
{# /.l-content #} + {{ feed_icons }} +
{# /.l-content #} - {% if page.sidebar_first %} - - {% endif %} + {% if page.sidebar_first %} + + {% endif %} - {% if page.sidebar_second %} - - {% endif %} + {% if page.sidebar_second %} + + {% endif %} -
+
- {% if page.footer %} -
- {{ page.footer }} -
- {% endif %} + {% if page.footer %} +
+ {{ page.footer }} +
+ {% endif %} -
{# /.l-container #} + {# /.l-container #} + {{ page_bottom }} + + diff --git a/core/modules/system/tests/modules/theme_test/theme_test.module b/core/modules/system/tests/modules/theme_test/theme_test.module index b6f13c8..8a0b433 100644 --- a/core/modules/system/tests/modules/theme_test/theme_test.module +++ b/core/modules/system/tests/modules/theme_test/theme_test.module @@ -58,7 +58,7 @@ function theme_test_theme($existing, $type, $theme, $path) { /** * Implements hook_preprocess_HOOK() for HTML document templates. */ -function theme_test_preprocess_html(&$variables) { +function theme_test_preprocess_page(&$variables) { $variables['html_attributes']['theme_test_html_attribute'] = 'theme test html attribute value'; $variables['attributes']['theme_test_body_attribute'] = 'theme test body attribute value'; diff --git a/core/themes/bartik/templates/page.html.twig b/core/themes/bartik/templates/page.html.twig index 5602997..d127124 100644 --- a/core/themes/bartik/templates/page.html.twig +++ b/core/themes/bartik/templates/page.html.twig @@ -3,10 +3,6 @@ * @file * Bartik's theme implementation to display a single page. * - * The doctype, html, head and body tags are not in this template. Instead they - * can be found in the html.html.twig template normally located in the - * core/modules/system directory. - * * Available variables: * * General utility variables: @@ -16,6 +12,20 @@ * - logged_in: A flag indicating if the user is registered and signed in. * - is_admin: A flag indicating if the user has permission to access * administration pages. + * - 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. + * - page_bottom: Closing rendered markup. + * - 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. * * Site identity: * - front_page: The URL of the front page. Use this instead of base_path when @@ -74,139 +84,154 @@ * * @see template_preprocess_page() * @see bartik_preprocess_page() - * @see html.html.twig * * @ingroup themeable */ #} -
- - - - {% if messages %} -
- {{ messages }} -
- {% endif %} - - {% if page.featured %} - - {% endif %} - -
- {{ breadcrumb }} - -
- {% if page.highlighted %}
{{ page.highlighted }}
{% endif %} - - {{ title_prefix }} - {% if title %} -

- {{ title }} -

+ + {{ page.header }} + + {% if main_menu %} + {% endif %} - {{ title_suffix }} - {% if tabs %} - +
+ + {% if messages %} +
+ {{ messages }} +
+ {% endif %} + + {% if page.featured %} + + {% endif %} + +
+ {{ breadcrumb }} + +
+ {% if page.highlighted %}
{{ page.highlighted }}
{% endif %} + + {{ title_prefix }} + {% if title %} +

+ {{ title }} +

+ {% endif %} + {{ title_suffix }} + {% if tabs %} + + {% endif %} + {{ page.help }} + {% if action_links %} + + {% endif %} + {{ page.content }} + {{ feed_icons }} +
+ + {% if page.sidebar_first %} + {% endif %} - {{ page.help }} - {% if action_links %} - + + {% if page.sidebar_second %} + {% endif %} - {{ page.content }} - {{ feed_icons }} - - - {% if page.sidebar_first %} - - {% endif %} - - {% if page.sidebar_second %} - - {% endif %} - -
- - {% if page.triptych_first or page.triptych_middle or page.triptych_last %} -
- {% endif %} - - - -
+ +
+ + {% if page.triptych_first or page.triptych_middle or page.triptych_last %} +
+ {% endif %} + + + + + {{ page_bottom }} + + diff --git a/core/themes/seven/install-page.html.twig b/core/themes/seven/install-page.html.twig index 1e9a1c2..c7a9b34 100644 --- a/core/themes/seven/install-page.html.twig +++ b/core/themes/seven/install-page.html.twig @@ -3,8 +3,7 @@ * @file * Seven theme implementation to display a Drupal installation page. * - * All the available variables are mirrored in html.html.twig and - * page.html.twig. + * All the available variables are mirrored in page.html.twig. * Some may be blank but they are provided for consistency. * * @see template_preprocess_install_page() diff --git a/core/themes/seven/templates/page.html.twig b/core/themes/seven/templates/page.html.twig index 77dde87..637e8e6 100644 --- a/core/themes/seven/templates/page.html.twig +++ b/core/themes/seven/templates/page.html.twig @@ -3,10 +3,6 @@ * @file * Seven's theme implementation to display a single Drupal page. * - * The doctype, html, head, and body tags are not in this template. Instead - * they can be found in the html.html.twig template normally located in the - * core/modules/system directory. - * * Available variables: * * General utility variables: @@ -60,7 +56,6 @@ * * @see template_preprocess_page() * @see seven_preprocess_page() - * @see html.html.twig * * @ingroup themeable */