diff --git a/core/includes/theme.inc b/core/includes/theme.inc index 29bcec1..9b16bab 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -2201,7 +2201,7 @@ function _template_preprocess_item_list_item(&$item) { */ function _template_preprocess_item_list_attributes(&$item) { if (is_array($item)) { - $attributes = array_diff_key($item, array('data' => 0, 'children' => 0, 'type' => 0)); + $attributes = array_diff_key($item, array('data' => 0, 'children' => 0, 'type' => 0, 'dt' => 0, 'dd' => 0)); // Attributes. (Always set). // @see http://drupal.org/node/1806066#comment-6577500 $item['attributes'] = new Attribute(array()); diff --git a/core/themes/stark/templates/theme.inc/item-list.html.twig b/core/themes/stark/templates/theme.inc/item-list.html.twig index cb41854..39c0976 100644 --- a/core/themes/stark/templates/theme.inc/item-list.html.twig +++ b/core/themes/stark/templates/theme.inc/item-list.html.twig @@ -10,9 +10,12 @@ * - children: A list of nested child items to render that behave * identically to 'items', but any non-numeric string keys are treated as * HTML attributes for the child list that wraps 'children'. + * - dt: An array of terms for the item when it is in a definition list. + * - dd: An array of definitions for the item when it is in a definition list. * - attributes: The attributes applied to the list item. + * - type: The type of list to return (e.g. "ul", "ol", or "dl"). * - title: The title of the list. - * - type: The type of list to return (e.g. "ul", "ol"). + * - type: The type of list to return (e.g. "ul", "ol", or "dl"). * - attributes: The attributes applied to the list element. * * @see template_preprocess @@ -21,24 +24,53 @@ * @ingroup themable */ #} +{# @todo: Rename this file to list.html.twig if this template handles all list types. #} {% if items %} -
{# @TODO remove this wrapper div #} +
{# @TODO remove this wrapper div or change class to 'html-list' #} {%- if title -%}

{{ title }}

{% endif %} - <{{ type }} class="{{ attributes.class }}" {{ attributes }}> - {% for item in items -%} - {% set value = item.data ? item.data : item %} -
  • {{- value -}} - {% if item.children %} - {%- include "core/themes/stark/templates/theme.inc/item-list.html.twig" with { - 'items': item.children, - 'title': item.title ? item.title : '', - 'type': item.type ? item.type : type, - 'attributes': item.attributes ? item.attributes : '' - } -%} - {% endif -%} -
  • + <{{ type }} {{ attributes }}> + {% for item in items %} + + {# + Handle
  • and
    /
    items differently. + @todo: Handle this in _preprocess and use different templates + set via hook_template_suggestions_HOOK? + #} + {% if item.dt %} + + {# Definition list items (
    /
    ). #} + {# One or more
    can be followed by one or more
    . #} + {% for term in item.dt %} +
    {{ term }}
    + {% endfor %} + {% if item.dd %} {#
    are optional. #} + {% for definition in item.dd %} + {# @todo: Support
    attributes and children (nested lists, as below)?. #} +
    {{ definition }}
    + {% endfor %} + {% endif %} + + {# Non-string list items (i.e.
  • with attributes or children). #} + {% elseif item.data is defined or item.children is defined %} +
  • {{- item.data -}} + {% if item.children %} + {%- include "core/themes/stark/templates/theme.inc/item-list.html.twig" with { + 'items': item.children, + 'title': item.title ? item.title : '', + 'type': item.type ? item.type : type, + 'attributes': item.attributes ? item.attributes : '' + } -%} + {% endif -%} +
  • + + {# Simple string items. #} + {% else %} +
  • {{- item -}}
  • + + {% endif %} + {% endfor -%}
    {# @TODO remove this wrapper div #}