commit 8918472e14041b1033ddf0eca6a57efb2ba1f59c Author: Joel Pittet Date: Mon Mar 31 18:47:15 2014 -0700 convert field__node__title diff --git a/core/includes/theme.inc b/core/includes/theme.inc index 3276d3d..f435e1e 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -2438,17 +2438,24 @@ function template_preprocess_field(&$variables, $hook) { $variables['title_attributes'] = isset($variables['title_attributes']) ? new Attribute($variables['title_attributes']) : clone($default_attributes); $variables['content_attributes'] = isset($variables['content_attributes']) ? new Attribute($variables['content_attributes']) : clone($default_attributes); - // Modules (e.g., rdf.module) can add field item attributes (to - // $item->_attributes) within hook_entity_prepare_view(). Some field - // formatters move those attributes into some nested formatter-specific - // element in order have them rendered on the desired HTML element (e.g., on - // the element of a field item being rendered as a link). Other field - // formatters leave them within $element['#items'][$delta]['_attributes'] to - // be rendered on the item wrappers provided by field.html.twig. + // We want other preprocess functions and the theme implementation to have + // fast access to the field item render arrays. The item render array keys + // (deltas) should always be numerically indexed starting from 0, and looping + // on those keys is faster than calling element_children() or looping on all + // keys within $element, since that requires traversal of all element + // properties. $variables['items'] = array(); $delta = 0; while (!empty($element[$delta])) { $variables['items'][$delta]['value'] = $element[$delta]; + + // Modules (e.g., rdf.module) can add field item attributes (to + // $item->_attributes) within hook_entity_prepare_view(). Some field + // formatters move those attributes into some nested formatter-specific + // element in order have them rendered on the desired HTML element (e.g., on + // the element of a field item being rendered as a link). Other field + // formatters leave them within $element['#items'][$delta]['_attributes'] to + // be rendered on the item wrappers provided by field.html.twig. $variables['items'][$delta]['attributes'] = !empty($element['#items'][$delta]->_attributes) ? new Attribute($element['#items'][$delta]->_attributes) : clone($default_attributes); $delta++; } diff --git a/core/modules/node/node.module b/core/modules/node/node.module index a5f0b00..b80b1d3 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -705,23 +705,6 @@ function template_preprocess_node(&$variables) { } /** - * Returns HTML for the node title field. - * - * This is an override of theme_field() for the node title field. See that - * function for documentation about its details and overrides. - * - * @param array $variables - * An associative array. See theme_field() for details. - * - * @see theme_field() - * - * @ingroup themeable - */ -function theme_field__node__title($variables) { - return '' . drupal_render($variables['items']) . ''; -} - -/** * Implements hook_permission(). */ function node_permission() { diff --git a/core/modules/node/templates/field--node--title.html.twig b/core/modules/node/templates/field--node--title.html.twig new file mode 100644 index 0000000..e0dda0f --- /dev/null +++ b/core/modules/node/templates/field--node--title.html.twig @@ -0,0 +1,37 @@ +{# +/** + * @file + * Default theme implementation for a field. + * + * To override output, copy the "field.html.twig" from the templates directory + * to your theme's directory and customize it, just like customizing other + * Drupal templates such as page.html.twig or node.html.twig. + * + * For example, for a field named 'body' displayed on the 'article' content + * type, any of the following templates will override this default + * implementation. The first of these templates that exists is used: + * - field--body--article.html.twig + * - field--article.html.twig + * - field--body.html.twig + * - field.html.twig + * + * Available variables: + * - attributes: HTML attributes for the containing element. + * - label_hidden: Whether to show the field label or not. + * - title_attributes: HTML attributes for the title. + * - label: The label for the field. + * - content_attributes: HTML attributes for the content. + * - items: List of all the field items. Each item contains: + * - attributes: List of HTML attributes for each item. + * - value: The field item's value. + * + * @see template_preprocess_field() + * + * @ingroup themeable + */ +#} + + {%- for item in items -%} + {{ item.value }} + {%- endfor -%} +