Move all logic from theme_item_list() to bootstrap_preprocess_item_list(). Override item-list.html.twig to remove useless div.item-list wrapper.

CommentFileSizeAuthor
#1 bootstrap-item-list-2260659-1.patch6.03 KBm1r1k
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

m1r1k’s picture

Status: Active » Needs review
FileSize
6.03 KB
m1r1k’s picture

markhalliwell’s picture

Assigned: m1r1k » Unassigned
Priority: Major » Normal
Status: Needs review » Needs work
  1. +++ b/theme/system/item-list.html.twig
    @@ -0,0 +1,39 @@
    + * @see template_preprocess_item_list()
    + * @see bootstrap_preprocess_item_list()
    

    Move above core's implementation.

  2. +++ b/theme/system/item-list.html.twig
    @@ -0,0 +1,39 @@
    +    {%- if title -%}
    +      {{ title }}
    +    {%- endif -%}
    
    +++ b/theme/system/item-list.vars.php
    @@ -0,0 +1,40 @@
    +    // @todo implement #type => html_tag here
    +    // Set defaults.
    +    $title += array(
    +      'level' => 'h3',
    +      'attributes' => array(),
    +    );
    +    // Heading outputs only when it has text.
    +    if (!empty($title['text'])) {
    +      $variables['title'] = '<' . $title['level'] . new Attribute($title['attributes']) . '>';
    +      $variables['title'] .= empty($title['html']) ? String::checkPlain($title['text']) : $title['text'];
    +      $variables['title'] .= '</' . $title['level'] . '>';
    +    }
    

    I agree, this should be html_tag instead here and just make the title a renderable array. Twig will automatically render it when it's printed.

markhalliwell’s picture

Status: Needs work » Closed (won't fix)

We don't need to override this template anymore.