I'm attempting to create an unordered list using a render array in a custom block in a custom module.
I understand if I wanted to wrap things in div I could always use the 'container' type. Like so
$content = [
'container' => [
'#type' => 'container',
'#attributes' => [
'class' => ['container'],
],
'item 1' => [
'#type' => 'html_tag',
'#tag' => 'p',
'#value' => 'Item 1',
],
'item 2' => [
'#type' => 'html_tag',
'#tag' => 'p',
'#value' => 'Item 2',
],
],
];
But I'd like to be able to use an unordered list like so
$content = [
'container' => [
'#type' => 'html_tag',
'#attributes' => [
'class' => ['container'],
],
'#tag' => 'ul',
'item 1' => [
'#type' => 'html_tag',
'#tag' => 'li',
'#value' => 'Item 1',
],
'item 2' => [
'#type' => 'html_tag',
'#tag' => 'li',
'#value' => 'Item 2',
],
],
];
What I'd like that to produce is
<ul class="container">
<li>Item 1</li>
<li>Item 2</li>
</ul>
But instead it produces
<ul class="container"></ul>
<li>Item 1</li>
<li>Item 2</li>
Is there a way to create an unordered list using render arrays?