Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/large-teachers-roll.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@cloudfour/patterns': patch
---

Fix issue with Comment `replies` block not working
25 changes: 17 additions & 8 deletions src/components/comment/comment.twig
Original file line number Diff line number Diff line change
Expand Up @@ -113,18 +113,27 @@
<h{{_section_heading_depth}} class="u-hidden-visually">
Replies to {{comment.author.name}}
</h{{_section_heading_depth}}>

{#
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 %}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm open to other ideas if there's a less yucky way to handle this. This needs to be defined after _child_heading_depth is set

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is fine 👍


{% 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 %}
Expand Down