From fe09f58c68908d4c5dcda26670f61df4ffa6b448 Mon Sep 17 00:00:00 2001 From: effulgentsia <alex.bronstein@acquia.com> Date: Wed, 4 Aug 2021 08:02:41 -0700 Subject: [PATCH] Issue #2993647 by AdamPS, alexpott, ravi.shankar, jonathanshaw, donquixote, lauriii, Wim Leers, larowlan, rodrigoaguilera: Correctly determine when to display fields as inline --- .../Controller/EntityViewController.php | 6 +- core/modules/node/node.module | 26 +++++ .../templates/field--node--created.html.twig | 11 ++ .../templates/field--node--title.html.twig | 11 ++ .../node/templates/field--node--uid.html.twig | 11 ++ .../NodeDisplayConfigurableTest.php | 104 +++++++++++++++--- .../field/field--node--created.html.twig | 10 ++ .../classy/field/field--node--title.html.twig | 10 ++ .../classy/field/field--node--uid.html.twig | 10 ++ .../Core/Theme/ConfirmClassyCopiesTest.php | 6 +- .../field/field--node--created.html.twig | 10 ++ .../classy/field/field--node--title.html.twig | 10 ++ .../classy/field/field--node--uid.html.twig | 10 ++ .../field/field--node--created.html.twig | 10 ++ .../classy/field/field--node--title.html.twig | 10 ++ .../classy/field/field--node--uid.html.twig | 10 ++ .../field/field--node--created.html.twig | 10 ++ .../field/field--node--title.html.twig | 10 ++ .../field/field--node--uid.html.twig | 10 ++ .../field/field--node--created.html.twig | 10 ++ .../classy/field/field--node--title.html.twig | 10 ++ .../classy/field/field--node--uid.html.twig | 10 ++ .../field/field--node--created.html.twig | 10 ++ .../field/field--node--title.html.twig | 10 ++ .../field/field--node--uid.html.twig | 10 ++ .../field/field--node--created.html.twig | 10 ++ .../field/field--node--title.html.twig | 10 ++ .../field/field--node--uid.html.twig | 10 ++ .../field/field--node--created.html.twig | 10 ++ .../field/field--node--title.html.twig | 10 ++ .../field/field--node--uid.html.twig | 10 ++ 31 files changed, 397 insertions(+), 18 deletions(-) diff --git a/core/lib/Drupal/Core/Entity/Controller/EntityViewController.php b/core/lib/Drupal/Core/Entity/Controller/EntityViewController.php index 1a2df9f50d74..c5ee7caf98d3 100644 --- a/core/lib/Drupal/Core/Entity/Controller/EntityViewController.php +++ b/core/lib/Drupal/Core/Entity/Controller/EntityViewController.php @@ -67,10 +67,14 @@ public function buildTitle(array $page) { // If the entity's label is rendered using a field formatter, set the // rendered title field formatter as the page title instead of the default // plain text title. This allows attributes set on the field to propagate - // correctly (e.g. RDFa, in-place editing). + // correctly (e.g. in-place editing). if ($entity instanceof FieldableEntityInterface) { $label_field = $entity->getEntityType()->getKey('label'); if (isset($page[$label_field])) { + // Allow templates and theme functions to generate different markup + // for the page title, which must be inline markup as it will be placed + // inside <h1>. See field--node--title.html.twig. + $page[$label_field]['#is_page_title'] = TRUE; $page['#title'] = $this->renderer->render($page[$label_field]); } } diff --git a/core/modules/node/node.module b/core/modules/node/node.module index 35176e5973a3..a09512492dc3 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -115,6 +115,8 @@ function node_theme() { 'node_edit_form' => [ 'render element' => 'form', ], + // @todo Delete the next three entries as part of + // https://www.drupal.org/node/3015623 'field__node__title' => [ 'base hook' => 'field', ], @@ -427,6 +429,30 @@ function node_preprocess_block(&$variables) { } } +/** + * Implements hook_preprocess_HOOK() for node field templates. + */ +function node_preprocess_field__node(&$variables) { + // Set a variable 'is_inline' in cases where inline markup is required, + // without any block elements such as <div>. + + if ($variables['element']['#is_page_title'] ?? FALSE) { + // Page title is always inline because it will be displayed inside <h1>. + $variables['is_inline'] = TRUE; + } + elseif (in_array($variables['field_name'], ['created', 'uid', 'title'], TRUE)) { + // Display created, uid and title fields inline because they will be + // displayed inline by node.html.twig. Skip this if the field + // display is configurable and skipping has been enabled. + // @todo Delete as part of https://www.drupal.org/node/3015623 + + /** @var \Drupal\node\NodeInterface $node */ + $node = $variables['element']['#object']; + $skip_custom_preprocessing = $node->getEntityType()->get('enable_base_field_custom_preprocess_skipping'); + $variables['is_inline'] = !$skip_custom_preprocessing || !$node->getFieldDefinition($variables['field_name'])->isDisplayConfigurable('view'); + } +} + /** * Implements hook_theme_suggestions_HOOK(). */ diff --git a/core/modules/node/templates/field--node--created.html.twig b/core/modules/node/templates/field--node--created.html.twig index 049144f50d95..e28ca36d59b1 100644 --- a/core/modules/node/templates/field--node--created.html.twig +++ b/core/modules/node/templates/field--node--created.html.twig @@ -15,14 +15,25 @@ * - field_name: The name of the field. * - field_type: The type of the field. * - label_display: The display settings for the label. + * - is_inline: If false, display an ordinary field. + * If true, display an inline format, suitable for inside elements such as + * <span>, <h2> and so on. * * @see field.html.twig + * @see node_preprocess_field__node() * * @ingroup themeable + * + * @todo Delete as part of https://www.drupal.org/node/3015623 */ #} + +{% if not is_inline %} + {% include "field.html.twig" %} +{% else %} <span{{ attributes }}> {%- for item in items -%} {{ item.content }} {%- endfor -%} </span> +{% endif %} diff --git a/core/modules/node/templates/field--node--title.html.twig b/core/modules/node/templates/field--node--title.html.twig index 68142ca5d1b0..e6d0faaa9b9c 100644 --- a/core/modules/node/templates/field--node--title.html.twig +++ b/core/modules/node/templates/field--node--title.html.twig @@ -15,14 +15,25 @@ * - field_name: The name of the field. * - field_type: The type of the field. * - label_display: The display settings for the label. + * - is_inline: If false, display an ordinary field. + * If true, display an inline format, suitable for inside elements such as + * <span>, <h2> and so on. * * @see field.html.twig + * @see node_preprocess_field__node() * * @ingroup themeable + * + * @todo Delete as part of https://www.drupal.org/node/3015623 */ #} + +{% if not is_inline %} + {% include "field.html.twig" %} +{% else %} <span{{ attributes }}> {%- for item in items -%} {{ item.content }} {%- endfor -%} </span> +{% endif %} diff --git a/core/modules/node/templates/field--node--uid.html.twig b/core/modules/node/templates/field--node--uid.html.twig index 91a97b3a9bf8..8f66a5bf777c 100644 --- a/core/modules/node/templates/field--node--uid.html.twig +++ b/core/modules/node/templates/field--node--uid.html.twig @@ -15,14 +15,25 @@ * - field_name: The name of the field. * - field_type: The type of the field. * - label_display: The display settings for the label. + * - is_inline: If false, display an ordinary field. + * If true, display an inline format, suitable for inside elements such as + * <span>, <h2> and so on. * * @see field.html.twig + * @see node_preprocess_field__node() * * @ingroup themeable + * + * @todo Delete as part of https://www.drupal.org/node/3015623 */ #} + +{% if not is_inline %} + {% include "field.html.twig" %} +{% else %} <span{{ attributes }}> {%- for item in items -%} {{ item.content }} {%- endfor -%} </span> +{% endif %} diff --git a/core/modules/node/tests/src/Functional/NodeDisplayConfigurableTest.php b/core/modules/node/tests/src/Functional/NodeDisplayConfigurableTest.php index 09876517b8bb..46cf6da90bca 100644 --- a/core/modules/node/tests/src/Functional/NodeDisplayConfigurableTest.php +++ b/core/modules/node/tests/src/Functional/NodeDisplayConfigurableTest.php @@ -3,6 +3,8 @@ namespace Drupal\Tests\node\Functional; use Drupal\Core\Entity\Entity\EntityViewDisplay; +use Drupal\node\NodeInterface; +use Drupal\user\UserInterface; /** * Tests making node base fields' displays configurable. @@ -16,17 +18,43 @@ class NodeDisplayConfigurableTest extends NodeTestBase { * * @var array */ - protected static $modules = ['quickedit', 'rdf']; + protected static $modules = ['quickedit', 'rdf', 'block']; /** * {@inheritdoc} */ protected $defaultTheme = 'classy'; + /** + * {@inheritdoc} + */ + protected function setUp(): void { + parent::setUp(); + $data = $this->getProvidedData(); + $theme = reset($data); + \Drupal::service('theme_installer')->install([$theme]); + $this->config('system.theme')->set('default', $theme)->save(); + $settings = [ + 'theme' => $theme, + 'region' => 'content', + 'weight' => -100, + ]; + $this->drupalPlaceBlock('page_title_block', $settings); + } + /** * Sets base fields to configurable display and check settings are respected. + * + * @param string $theme + * The name of the theme being tested. + * @param string $metadata_region + * The region of the node html content where meta data is expected. + * @param bool $field_classes + * If TRUE, check for field--name-XXX classes. + * + * @dataProvider provideThemes */ - public function testDisplayConfigurable() { + public function testDisplayConfigurable(string $theme, string $metadata_region, bool $field_classes) { // Change the node type setting to show submitted by information. $node_type = \Drupal::entityTypeManager()->getStorage('node_type')->load('page'); $node_type->setDisplaySubmitted(TRUE); @@ -35,17 +63,14 @@ public function testDisplayConfigurable() { $user = $this->drupalCreateUser([ 'access in-place editing', 'administer nodes', - ]); + ], $this->randomMachineName(14)); $this->drupalLogin($user); $node = $this->drupalCreateNode(['uid' => $user->id()]); $assert = $this->assertSession(); // Check the node with Drupal default non-configurable display. $this->drupalGet($node->toUrl()); - $assert->elementTextContains('css', 'span.field--name-created', \Drupal::service('date.formatter')->format($node->getCreatedTime())); - $assert->elementTextContains('css', 'span.field--name-uid[data-quickedit-field-id="node/1/uid/en/full"]', $user->getAccountName()); - $assert->elementTextContains('css', 'div.node__submitted', 'Submitted by'); - $assert->elementTextContains('css', 'span.field--name-title', $node->getTitle()); + $this->assertNodeHtml($node, $user, 'span', $metadata_region, $field_classes); // Enable module to make base fields' displays configurable. \Drupal::service('module_installer')->install(['node_display_configurable_test']); @@ -62,11 +87,8 @@ public function testDisplayConfigurable() { // Recheck the node with configurable display. $this->drupalGet($node->toUrl()); - $assert->elementTextContains('css', 'span.field--name-created', \Drupal::service('date.formatter')->format($node->getCreatedTime())); - $assert->elementTextContains('css', 'span.field--name-uid[data-quickedit-field-id="node/1/uid/en/full"]', $user->getAccountName()); - $assert->elementNotExists('css', 'span.field--name-uid a'); - $assert->elementTextContains('css', 'span.field--name-title', $node->getTitle()); - $assert->elementExists('css', 'span[property="schema:dateCreated"]'); + + $this->assertNodeHtml($node, $user, 'div', $metadata_region, $field_classes); // Remove from display. $display->removeComponent('uid') @@ -74,8 +96,62 @@ public function testDisplayConfigurable() { ->save(); $this->drupalGet($node->toUrl()); - $assert->elementNotExists('css', '.field--name-created'); - $assert->elementNotExists('css', '.field--name-uid'); + $assert->elementNotExists('css', 'div[data-quickedit-field-id="node/1/uid/en/full"]'); + $assert->elementTextNotContains('css', 'article[data-quickedit-entity-id="node/1"]', $user->getAccountName()); + } + + /** + * Asserts that the node HTML is as expected. + * + * @param \Drupal\node\NodeInterface $node + * The node being tested. + * @param \Drupal\user\UserInterface $user + * The logged in user. + * @param string $html_element + * Either 'div' or 'span' + * @param string $metadata_region + * The region of the node html content where meta data is expected. + * @param bool $field_classes + * If TRUE, check for field--name-XXX classes. + */ + protected function assertNodeHtml(NodeInterface $node, UserInterface $user, string $html_element, string $metadata_region, bool $field_classes) { + $assert = $this->assertSession(); + + $title_selector = 'h1 span' . ($field_classes ? '.field--name-title' : '') . '[data-quickedit-field-id="node/1/title/en/full"]'; + $created_selector = 'article[data-quickedit-entity-id="node/1"] ' . $html_element . ($field_classes ? '.field--name-created' : '') . '[data-quickedit-field-id="node/1/created/en/full"]'; + $uid_selector = 'article[data-quickedit-entity-id="node/1"] ' . $html_element . ($field_classes ? '.field--name-uid' : '') . '[data-quickedit-field-id="node/1/uid/en/full"]'; + + $assert->elementTextContains('css', $title_selector, $node->getTitle()); + $assert->elementTextContains('css', $created_selector, \Drupal::service('date.formatter')->format($node->getCreatedTime())); + if ($html_element === 'div') { + $assert->elementTextContains('css', "$uid_selector $html_element" . '[rel="schema:author"]', $user->getAccountName()); + $assert->elementNotExists('css', "$uid_selector a"); + $assert->elementTextContains('css', "$uid_selector $html_element", 'Authored by'); + $assert->elementExists('css', 'span[property="schema:dateCreated"]'); + } + else { + $assert->elementTextContains('css', $uid_selector . ' a[property="schema:name"]', $user->getAccountName()); + $assert->elementTextContains('css', 'article[data-quickedit-entity-id="node/1"] ' . $metadata_region, 'Submitted by'); + } + } + + /** + * Data provider for ::testDisplayConfigurable(). + * + * @return array + */ + public function provideThemes() { + return [ + ['bartik', 'header', TRUE], + ['claro', 'footer', TRUE], + ['classy', 'footer', TRUE], + // @todo Add coverage for olivero after fixing + // https://www.drupal.org/project/drupal/issues/3215220. + // ['olivero', 'footer', TRUE], + ['seven', 'footer', TRUE], + ['stable', 'footer', FALSE], + ['stable9', 'footer', FALSE], + ]; } } diff --git a/core/profiles/demo_umami/themes/umami/templates/classy/field/field--node--created.html.twig b/core/profiles/demo_umami/themes/umami/templates/classy/field/field--node--created.html.twig index 72d5d6737d26..f4d1acd439b4 100644 --- a/core/profiles/demo_umami/themes/umami/templates/classy/field/field--node--created.html.twig +++ b/core/profiles/demo_umami/themes/umami/templates/classy/field/field--node--created.html.twig @@ -15,10 +15,19 @@ * - field_name: The name of the field. * - field_type: The type of the field. * - label_display: The display settings for the label. + * - is_inline: If false, display an ordinary field. + * If true, display an inline format, suitable for inside elements such as + * <span>, <h2> and so on. * * @see field.html.twig + * @see node_preprocess_field__node() + * + * @todo Delete as part of https://www.drupal.org/node/3015623 */ #} +{% if not is_inline %} + {% include "field.html.twig" %} +{% else %} {% set classes = [ 'field', @@ -32,3 +41,4 @@ {{ item.content }} {%- endfor -%} </span> +{% endif %} diff --git a/core/profiles/demo_umami/themes/umami/templates/classy/field/field--node--title.html.twig b/core/profiles/demo_umami/themes/umami/templates/classy/field/field--node--title.html.twig index 33b105f50b3e..e79c39eb52cc 100644 --- a/core/profiles/demo_umami/themes/umami/templates/classy/field/field--node--title.html.twig +++ b/core/profiles/demo_umami/themes/umami/templates/classy/field/field--node--title.html.twig @@ -15,10 +15,19 @@ * - field_name: The name of the field. * - field_type: The type of the field. * - label_display: The display settings for the label. + * - is_inline: If false, display an ordinary field. + * If true, display an inline format, suitable for inside elements such as + * <span>, <h2> and so on. * * @see field.html.twig + * @see node_preprocess_field__node() + * + * @todo Delete as part of https://www.drupal.org/node/3015623 */ #} +{% if not is_inline %} + {% include "field.html.twig" %} +{% else %} {% set classes = [ 'field', @@ -32,3 +41,4 @@ {{ item.content }} {%- endfor -%} </span> +{% endif %} diff --git a/core/profiles/demo_umami/themes/umami/templates/classy/field/field--node--uid.html.twig b/core/profiles/demo_umami/themes/umami/templates/classy/field/field--node--uid.html.twig index 9afc591b7194..0a381083246a 100644 --- a/core/profiles/demo_umami/themes/umami/templates/classy/field/field--node--uid.html.twig +++ b/core/profiles/demo_umami/themes/umami/templates/classy/field/field--node--uid.html.twig @@ -15,10 +15,19 @@ * - field_name: The name of the field. * - field_type: The type of the field. * - label_display: The display settings for the label. + * - is_inline: If false, display an ordinary field. + * If true, display an inline format, suitable for inside elements such as + * <span>, <h2> and so on. * * @see field.html.twig + * @see node_preprocess_field__node() + * + * @todo Delete as part of https://www.drupal.org/node/3015623 */ #} +{% if not is_inline %} + {% include "field.html.twig" %} +{% else %} {% set classes = [ 'field', @@ -32,3 +41,4 @@ {{ item.content }} {%- endfor -%} </span> +{% endif %} diff --git a/core/tests/Drupal/KernelTests/Core/Theme/ConfirmClassyCopiesTest.php b/core/tests/Drupal/KernelTests/Core/Theme/ConfirmClassyCopiesTest.php index babc8efc145e..158071d6c556 100644 --- a/core/tests/Drupal/KernelTests/Core/Theme/ConfirmClassyCopiesTest.php +++ b/core/tests/Drupal/KernelTests/Core/Theme/ConfirmClassyCopiesTest.php @@ -812,10 +812,10 @@ protected function getClassyHash($type, $file) { 'field.html.twig' => '4da82841bf83d728ed2f3757de7402fb', 'file-link.html.twig' => '0f10f3e79ecb9b6e82ef30c66e4ebcc6', 'field--text-with-summary.html.twig' => '898425e3da212ed81ff01c7b624033fd', - 'field--node--uid.html.twig' => 'eec25d4a07d3447ba012a1f6bf8c2cea', - 'field--node--title.html.twig' => 'bd618d16c576614d2f2c6d3e60315559', + 'field--node--uid.html.twig' => 'd8b6b27f106d1494dca27efe7bf76c59', + 'field--node--title.html.twig' => '8b1830816fb75a0025965b5eb09c24c6', 'image-style.html.twig' => '6d2588a4453ed014601f66cd45baf00f', - 'field--node--created.html.twig' => '7a33b0533f7bd12cc81af52f4151cb7c', + 'field--node--created.html.twig' => 'e597e1c783d32862b85720ab08049339', 'image-formatter.html.twig' => '9bc966dd2fe1a913cd7a89fbd243d947', 'file-video.html.twig' => '9f58b817bf059a86300d2757c76f0d97', 'links--media-library-menu.html.twig' => '31f4f0f507af5dde490e9a992fa89db6', diff --git a/core/themes/bartik/templates/classy/field/field--node--created.html.twig b/core/themes/bartik/templates/classy/field/field--node--created.html.twig index 72d5d6737d26..f4d1acd439b4 100644 --- a/core/themes/bartik/templates/classy/field/field--node--created.html.twig +++ b/core/themes/bartik/templates/classy/field/field--node--created.html.twig @@ -15,10 +15,19 @@ * - field_name: The name of the field. * - field_type: The type of the field. * - label_display: The display settings for the label. + * - is_inline: If false, display an ordinary field. + * If true, display an inline format, suitable for inside elements such as + * <span>, <h2> and so on. * * @see field.html.twig + * @see node_preprocess_field__node() + * + * @todo Delete as part of https://www.drupal.org/node/3015623 */ #} +{% if not is_inline %} + {% include "field.html.twig" %} +{% else %} {% set classes = [ 'field', @@ -32,3 +41,4 @@ {{ item.content }} {%- endfor -%} </span> +{% endif %} diff --git a/core/themes/bartik/templates/classy/field/field--node--title.html.twig b/core/themes/bartik/templates/classy/field/field--node--title.html.twig index 33b105f50b3e..e79c39eb52cc 100644 --- a/core/themes/bartik/templates/classy/field/field--node--title.html.twig +++ b/core/themes/bartik/templates/classy/field/field--node--title.html.twig @@ -15,10 +15,19 @@ * - field_name: The name of the field. * - field_type: The type of the field. * - label_display: The display settings for the label. + * - is_inline: If false, display an ordinary field. + * If true, display an inline format, suitable for inside elements such as + * <span>, <h2> and so on. * * @see field.html.twig + * @see node_preprocess_field__node() + * + * @todo Delete as part of https://www.drupal.org/node/3015623 */ #} +{% if not is_inline %} + {% include "field.html.twig" %} +{% else %} {% set classes = [ 'field', @@ -32,3 +41,4 @@ {{ item.content }} {%- endfor -%} </span> +{% endif %} diff --git a/core/themes/bartik/templates/classy/field/field--node--uid.html.twig b/core/themes/bartik/templates/classy/field/field--node--uid.html.twig index 9afc591b7194..0a381083246a 100644 --- a/core/themes/bartik/templates/classy/field/field--node--uid.html.twig +++ b/core/themes/bartik/templates/classy/field/field--node--uid.html.twig @@ -15,10 +15,19 @@ * - field_name: The name of the field. * - field_type: The type of the field. * - label_display: The display settings for the label. + * - is_inline: If false, display an ordinary field. + * If true, display an inline format, suitable for inside elements such as + * <span>, <h2> and so on. * * @see field.html.twig + * @see node_preprocess_field__node() + * + * @todo Delete as part of https://www.drupal.org/node/3015623 */ #} +{% if not is_inline %} + {% include "field.html.twig" %} +{% else %} {% set classes = [ 'field', @@ -32,3 +41,4 @@ {{ item.content }} {%- endfor -%} </span> +{% endif %} diff --git a/core/themes/claro/templates/classy/field/field--node--created.html.twig b/core/themes/claro/templates/classy/field/field--node--created.html.twig index 72d5d6737d26..f4d1acd439b4 100644 --- a/core/themes/claro/templates/classy/field/field--node--created.html.twig +++ b/core/themes/claro/templates/classy/field/field--node--created.html.twig @@ -15,10 +15,19 @@ * - field_name: The name of the field. * - field_type: The type of the field. * - label_display: The display settings for the label. + * - is_inline: If false, display an ordinary field. + * If true, display an inline format, suitable for inside elements such as + * <span>, <h2> and so on. * * @see field.html.twig + * @see node_preprocess_field__node() + * + * @todo Delete as part of https://www.drupal.org/node/3015623 */ #} +{% if not is_inline %} + {% include "field.html.twig" %} +{% else %} {% set classes = [ 'field', @@ -32,3 +41,4 @@ {{ item.content }} {%- endfor -%} </span> +{% endif %} diff --git a/core/themes/claro/templates/classy/field/field--node--title.html.twig b/core/themes/claro/templates/classy/field/field--node--title.html.twig index 33b105f50b3e..e79c39eb52cc 100644 --- a/core/themes/claro/templates/classy/field/field--node--title.html.twig +++ b/core/themes/claro/templates/classy/field/field--node--title.html.twig @@ -15,10 +15,19 @@ * - field_name: The name of the field. * - field_type: The type of the field. * - label_display: The display settings for the label. + * - is_inline: If false, display an ordinary field. + * If true, display an inline format, suitable for inside elements such as + * <span>, <h2> and so on. * * @see field.html.twig + * @see node_preprocess_field__node() + * + * @todo Delete as part of https://www.drupal.org/node/3015623 */ #} +{% if not is_inline %} + {% include "field.html.twig" %} +{% else %} {% set classes = [ 'field', @@ -32,3 +41,4 @@ {{ item.content }} {%- endfor -%} </span> +{% endif %} diff --git a/core/themes/claro/templates/classy/field/field--node--uid.html.twig b/core/themes/claro/templates/classy/field/field--node--uid.html.twig index 9afc591b7194..0a381083246a 100644 --- a/core/themes/claro/templates/classy/field/field--node--uid.html.twig +++ b/core/themes/claro/templates/classy/field/field--node--uid.html.twig @@ -15,10 +15,19 @@ * - field_name: The name of the field. * - field_type: The type of the field. * - label_display: The display settings for the label. + * - is_inline: If false, display an ordinary field. + * If true, display an inline format, suitable for inside elements such as + * <span>, <h2> and so on. * * @see field.html.twig + * @see node_preprocess_field__node() + * + * @todo Delete as part of https://www.drupal.org/node/3015623 */ #} +{% if not is_inline %} + {% include "field.html.twig" %} +{% else %} {% set classes = [ 'field', @@ -32,3 +41,4 @@ {{ item.content }} {%- endfor -%} </span> +{% endif %} diff --git a/core/themes/classy/templates/field/field--node--created.html.twig b/core/themes/classy/templates/field/field--node--created.html.twig index 72d5d6737d26..f4d1acd439b4 100644 --- a/core/themes/classy/templates/field/field--node--created.html.twig +++ b/core/themes/classy/templates/field/field--node--created.html.twig @@ -15,10 +15,19 @@ * - field_name: The name of the field. * - field_type: The type of the field. * - label_display: The display settings for the label. + * - is_inline: If false, display an ordinary field. + * If true, display an inline format, suitable for inside elements such as + * <span>, <h2> and so on. * * @see field.html.twig + * @see node_preprocess_field__node() + * + * @todo Delete as part of https://www.drupal.org/node/3015623 */ #} +{% if not is_inline %} + {% include "field.html.twig" %} +{% else %} {% set classes = [ 'field', @@ -32,3 +41,4 @@ {{ item.content }} {%- endfor -%} </span> +{% endif %} diff --git a/core/themes/classy/templates/field/field--node--title.html.twig b/core/themes/classy/templates/field/field--node--title.html.twig index 33b105f50b3e..e79c39eb52cc 100644 --- a/core/themes/classy/templates/field/field--node--title.html.twig +++ b/core/themes/classy/templates/field/field--node--title.html.twig @@ -15,10 +15,19 @@ * - field_name: The name of the field. * - field_type: The type of the field. * - label_display: The display settings for the label. + * - is_inline: If false, display an ordinary field. + * If true, display an inline format, suitable for inside elements such as + * <span>, <h2> and so on. * * @see field.html.twig + * @see node_preprocess_field__node() + * + * @todo Delete as part of https://www.drupal.org/node/3015623 */ #} +{% if not is_inline %} + {% include "field.html.twig" %} +{% else %} {% set classes = [ 'field', @@ -32,3 +41,4 @@ {{ item.content }} {%- endfor -%} </span> +{% endif %} diff --git a/core/themes/classy/templates/field/field--node--uid.html.twig b/core/themes/classy/templates/field/field--node--uid.html.twig index 9afc591b7194..0a381083246a 100644 --- a/core/themes/classy/templates/field/field--node--uid.html.twig +++ b/core/themes/classy/templates/field/field--node--uid.html.twig @@ -15,10 +15,19 @@ * - field_name: The name of the field. * - field_type: The type of the field. * - label_display: The display settings for the label. + * - is_inline: If false, display an ordinary field. + * If true, display an inline format, suitable for inside elements such as + * <span>, <h2> and so on. * * @see field.html.twig + * @see node_preprocess_field__node() + * + * @todo Delete as part of https://www.drupal.org/node/3015623 */ #} +{% if not is_inline %} + {% include "field.html.twig" %} +{% else %} {% set classes = [ 'field', @@ -32,3 +41,4 @@ {{ item.content }} {%- endfor -%} </span> +{% endif %} diff --git a/core/themes/seven/templates/classy/field/field--node--created.html.twig b/core/themes/seven/templates/classy/field/field--node--created.html.twig index 72d5d6737d26..f4d1acd439b4 100644 --- a/core/themes/seven/templates/classy/field/field--node--created.html.twig +++ b/core/themes/seven/templates/classy/field/field--node--created.html.twig @@ -15,10 +15,19 @@ * - field_name: The name of the field. * - field_type: The type of the field. * - label_display: The display settings for the label. + * - is_inline: If false, display an ordinary field. + * If true, display an inline format, suitable for inside elements such as + * <span>, <h2> and so on. * * @see field.html.twig + * @see node_preprocess_field__node() + * + * @todo Delete as part of https://www.drupal.org/node/3015623 */ #} +{% if not is_inline %} + {% include "field.html.twig" %} +{% else %} {% set classes = [ 'field', @@ -32,3 +41,4 @@ {{ item.content }} {%- endfor -%} </span> +{% endif %} diff --git a/core/themes/seven/templates/classy/field/field--node--title.html.twig b/core/themes/seven/templates/classy/field/field--node--title.html.twig index 33b105f50b3e..e79c39eb52cc 100644 --- a/core/themes/seven/templates/classy/field/field--node--title.html.twig +++ b/core/themes/seven/templates/classy/field/field--node--title.html.twig @@ -15,10 +15,19 @@ * - field_name: The name of the field. * - field_type: The type of the field. * - label_display: The display settings for the label. + * - is_inline: If false, display an ordinary field. + * If true, display an inline format, suitable for inside elements such as + * <span>, <h2> and so on. * * @see field.html.twig + * @see node_preprocess_field__node() + * + * @todo Delete as part of https://www.drupal.org/node/3015623 */ #} +{% if not is_inline %} + {% include "field.html.twig" %} +{% else %} {% set classes = [ 'field', @@ -32,3 +41,4 @@ {{ item.content }} {%- endfor -%} </span> +{% endif %} diff --git a/core/themes/seven/templates/classy/field/field--node--uid.html.twig b/core/themes/seven/templates/classy/field/field--node--uid.html.twig index 9afc591b7194..0a381083246a 100644 --- a/core/themes/seven/templates/classy/field/field--node--uid.html.twig +++ b/core/themes/seven/templates/classy/field/field--node--uid.html.twig @@ -15,10 +15,19 @@ * - field_name: The name of the field. * - field_type: The type of the field. * - label_display: The display settings for the label. + * - is_inline: If false, display an ordinary field. + * If true, display an inline format, suitable for inside elements such as + * <span>, <h2> and so on. * * @see field.html.twig + * @see node_preprocess_field__node() + * + * @todo Delete as part of https://www.drupal.org/node/3015623 */ #} +{% if not is_inline %} + {% include "field.html.twig" %} +{% else %} {% set classes = [ 'field', @@ -32,3 +41,4 @@ {{ item.content }} {%- endfor -%} </span> +{% endif %} diff --git a/core/themes/stable/templates/field/field--node--created.html.twig b/core/themes/stable/templates/field/field--node--created.html.twig index e00837d3e08b..a9d394993e88 100644 --- a/core/themes/stable/templates/field/field--node--created.html.twig +++ b/core/themes/stable/templates/field/field--node--created.html.twig @@ -15,12 +15,22 @@ * - field_name: The name of the field. * - field_type: The type of the field. * - label_display: The display settings for the label. + * - is_inline: If false, display an ordinary field. + * If true, display an inline format, suitable for inside elements such as + * <span>, <h2> and so on. * * @see field.html.twig + * @see node_preprocess_field__node() + * + * @todo Delete as part of https://www.drupal.org/node/3015623 */ #} +{% if not is_inline %} + {% include "field.html.twig" %} +{% else %} <span{{ attributes }}> {%- for item in items -%} {{ item.content }} {%- endfor -%} </span> +{% endif %} diff --git a/core/themes/stable/templates/field/field--node--title.html.twig b/core/themes/stable/templates/field/field--node--title.html.twig index 5ab974f2ddb1..effe5c5daaad 100644 --- a/core/themes/stable/templates/field/field--node--title.html.twig +++ b/core/themes/stable/templates/field/field--node--title.html.twig @@ -15,12 +15,22 @@ * - field_name: The name of the field. * - field_type: The type of the field. * - label_display: The display settings for the label. + * - is_inline: If false, display an ordinary field. + * If true, display an inline format, suitable for inside elements such as + * <span>, <h2> and so on. * * @see field.html.twig + * @see node_preprocess_field__node() + * + * @todo Delete as part of https://www.drupal.org/node/3015623 */ #} +{% if not is_inline %} + {% include "field.html.twig" %} +{% else %} <span{{ attributes }}> {%- for item in items -%} {{ item.content }} {%- endfor -%} </span> +{% endif %} diff --git a/core/themes/stable/templates/field/field--node--uid.html.twig b/core/themes/stable/templates/field/field--node--uid.html.twig index af730dc02b5d..ee49c9ae207d 100644 --- a/core/themes/stable/templates/field/field--node--uid.html.twig +++ b/core/themes/stable/templates/field/field--node--uid.html.twig @@ -15,12 +15,22 @@ * - field_name: The name of the field. * - field_type: The type of the field. * - label_display: The display settings for the label. + * - is_inline: If false, display an ordinary field. + * If true, display an inline format, suitable for inside elements such as + * <span>, <h2> and so on. * * @see field.html.twig + * @see node_preprocess_field__node() + * + * @todo Delete as part of https://www.drupal.org/node/3015623 */ #} +{% if not is_inline %} + {% include "field.html.twig" %} +{% else %} <span{{ attributes }}> {%- for item in items -%} {{ item.content }} {%- endfor -%} </span> +{% endif %} diff --git a/core/themes/stable9/templates/field/field--node--created.html.twig b/core/themes/stable9/templates/field/field--node--created.html.twig index e00837d3e08b..a9d394993e88 100644 --- a/core/themes/stable9/templates/field/field--node--created.html.twig +++ b/core/themes/stable9/templates/field/field--node--created.html.twig @@ -15,12 +15,22 @@ * - field_name: The name of the field. * - field_type: The type of the field. * - label_display: The display settings for the label. + * - is_inline: If false, display an ordinary field. + * If true, display an inline format, suitable for inside elements such as + * <span>, <h2> and so on. * * @see field.html.twig + * @see node_preprocess_field__node() + * + * @todo Delete as part of https://www.drupal.org/node/3015623 */ #} +{% if not is_inline %} + {% include "field.html.twig" %} +{% else %} <span{{ attributes }}> {%- for item in items -%} {{ item.content }} {%- endfor -%} </span> +{% endif %} diff --git a/core/themes/stable9/templates/field/field--node--title.html.twig b/core/themes/stable9/templates/field/field--node--title.html.twig index 5ab974f2ddb1..effe5c5daaad 100644 --- a/core/themes/stable9/templates/field/field--node--title.html.twig +++ b/core/themes/stable9/templates/field/field--node--title.html.twig @@ -15,12 +15,22 @@ * - field_name: The name of the field. * - field_type: The type of the field. * - label_display: The display settings for the label. + * - is_inline: If false, display an ordinary field. + * If true, display an inline format, suitable for inside elements such as + * <span>, <h2> and so on. * * @see field.html.twig + * @see node_preprocess_field__node() + * + * @todo Delete as part of https://www.drupal.org/node/3015623 */ #} +{% if not is_inline %} + {% include "field.html.twig" %} +{% else %} <span{{ attributes }}> {%- for item in items -%} {{ item.content }} {%- endfor -%} </span> +{% endif %} diff --git a/core/themes/stable9/templates/field/field--node--uid.html.twig b/core/themes/stable9/templates/field/field--node--uid.html.twig index af730dc02b5d..ee49c9ae207d 100644 --- a/core/themes/stable9/templates/field/field--node--uid.html.twig +++ b/core/themes/stable9/templates/field/field--node--uid.html.twig @@ -15,12 +15,22 @@ * - field_name: The name of the field. * - field_type: The type of the field. * - label_display: The display settings for the label. + * - is_inline: If false, display an ordinary field. + * If true, display an inline format, suitable for inside elements such as + * <span>, <h2> and so on. * * @see field.html.twig + * @see node_preprocess_field__node() + * + * @todo Delete as part of https://www.drupal.org/node/3015623 */ #} +{% if not is_inline %} + {% include "field.html.twig" %} +{% else %} <span{{ attributes }}> {%- for item in items -%} {{ item.content }} {%- endfor -%} </span> +{% endif %} diff --git a/core/themes/starterkit_theme/templates/field/field--node--created.html.twig b/core/themes/starterkit_theme/templates/field/field--node--created.html.twig index 72d5d6737d26..f4d1acd439b4 100644 --- a/core/themes/starterkit_theme/templates/field/field--node--created.html.twig +++ b/core/themes/starterkit_theme/templates/field/field--node--created.html.twig @@ -15,10 +15,19 @@ * - field_name: The name of the field. * - field_type: The type of the field. * - label_display: The display settings for the label. + * - is_inline: If false, display an ordinary field. + * If true, display an inline format, suitable for inside elements such as + * <span>, <h2> and so on. * * @see field.html.twig + * @see node_preprocess_field__node() + * + * @todo Delete as part of https://www.drupal.org/node/3015623 */ #} +{% if not is_inline %} + {% include "field.html.twig" %} +{% else %} {% set classes = [ 'field', @@ -32,3 +41,4 @@ {{ item.content }} {%- endfor -%} </span> +{% endif %} diff --git a/core/themes/starterkit_theme/templates/field/field--node--title.html.twig b/core/themes/starterkit_theme/templates/field/field--node--title.html.twig index 33b105f50b3e..e79c39eb52cc 100644 --- a/core/themes/starterkit_theme/templates/field/field--node--title.html.twig +++ b/core/themes/starterkit_theme/templates/field/field--node--title.html.twig @@ -15,10 +15,19 @@ * - field_name: The name of the field. * - field_type: The type of the field. * - label_display: The display settings for the label. + * - is_inline: If false, display an ordinary field. + * If true, display an inline format, suitable for inside elements such as + * <span>, <h2> and so on. * * @see field.html.twig + * @see node_preprocess_field__node() + * + * @todo Delete as part of https://www.drupal.org/node/3015623 */ #} +{% if not is_inline %} + {% include "field.html.twig" %} +{% else %} {% set classes = [ 'field', @@ -32,3 +41,4 @@ {{ item.content }} {%- endfor -%} </span> +{% endif %} diff --git a/core/themes/starterkit_theme/templates/field/field--node--uid.html.twig b/core/themes/starterkit_theme/templates/field/field--node--uid.html.twig index 9afc591b7194..0a381083246a 100644 --- a/core/themes/starterkit_theme/templates/field/field--node--uid.html.twig +++ b/core/themes/starterkit_theme/templates/field/field--node--uid.html.twig @@ -15,10 +15,19 @@ * - field_name: The name of the field. * - field_type: The type of the field. * - label_display: The display settings for the label. + * - is_inline: If false, display an ordinary field. + * If true, display an inline format, suitable for inside elements such as + * <span>, <h2> and so on. * * @see field.html.twig + * @see node_preprocess_field__node() + * + * @todo Delete as part of https://www.drupal.org/node/3015623 */ #} +{% if not is_inline %} + {% include "field.html.twig" %} +{% else %} {% set classes = [ 'field', @@ -32,3 +41,4 @@ {{ item.content }} {%- endfor -%} </span> +{% endif %} -- GitLab