diff --git a/.changeset/large-teachers-roll.md b/.changeset/large-teachers-roll.md new file mode 100644 index 000000000..5aad4450e --- /dev/null +++ b/.changeset/large-teachers-roll.md @@ -0,0 +1,5 @@ +--- +'@cloudfour/patterns': patch +--- + +Fix issue with Comment `replies` block not working diff --git a/src/components/comment/comment.twig b/src/components/comment/comment.twig index 53065e25c..d77e052f6 100644 --- a/src/components/comment/comment.twig +++ b/src/components/comment/comment.twig @@ -113,18 +113,27 @@ Replies to {{comment.author.name}} + + {# + This is defined here, so we can pass it into the block of a nested embed. + @see https://benfurfie.co.uk/articles/how-to-nest-a-block-in-another-block-in-an-embed-in-twig + #} + {% set repliesContent %} + {% block replies %} + {% for child in comment.children %} + {% include '@cloudfour/components/comment/comment.twig' with { + comment: child, + heading_depth: _child_heading_depth, + } only %} + {% endfor %} + {% endblock %} + {% endset %} + {% embed '@cloudfour/objects/rhythm/rhythm.twig' with { class: 'c-comment__replies' } %} {% block content %} - {% block replies %} - {% for child in comment.children %} - {% include '@cloudfour/components/comment/comment.twig' with { - comment: child, - heading_depth: _child_heading_depth, - } only %} - {% endfor %} - {% endblock %} + {{ repliesContent }} {% endblock %} {% endembed %} {% endif %}