From 6fa0c3a0511c8bbe7f1d7d1af37f484dc991cc06 Mon Sep 17 00:00:00 2001 From: Paul Hebert Date: Wed, 25 Aug 2021 13:00:02 -0700 Subject: [PATCH] Add `comment_content` block to Comments This will make it easier to apply Twig transforms on the Wordpress side. Initially I thought I could instead manipulate the comments with PHP, but ran into issues with `comment.children` being a protected property. --- .changeset/seven-students-impress.md | 5 +++++ src/components/comment/comment.stories.mdx | 1 + src/components/comment/comment.twig | 4 +++- 3 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 .changeset/seven-students-impress.md diff --git a/.changeset/seven-students-impress.md b/.changeset/seven-students-impress.md new file mode 100644 index 000000000..960acf3d9 --- /dev/null +++ b/.changeset/seven-students-impress.md @@ -0,0 +1,5 @@ +--- +'@cloudfour/patterns': minor +--- + +Add `comment_content` block to Comments diff --git a/src/components/comment/comment.stories.mdx b/src/components/comment/comment.stories.mdx index 31f261951..8bb28ff5a 100644 --- a/src/components/comment/comment.stories.mdx +++ b/src/components/comment/comment.stories.mdx @@ -310,6 +310,7 @@ While it is theoretically possible to infinitely nest `children`, it's recommend - `replies`: Use to pass in your own replies markup. This is useful if you need to modify other blocks within replies. - `reply_form`: Can be used to replace the entire reply form - `reply_form_hidden_inputs`: Can be used to add hidden inputs to the comment reply form. This can be useful for integrating with systems like Wordpress which use these provide additional context during form submission. +- `comment_content`: Can be used to replace the comment content. Can be useful if ## JavaScript Instructions diff --git a/src/components/comment/comment.twig b/src/components/comment/comment.twig index 2ca92afe1..3c4422cf6 100644 --- a/src/components/comment/comment.twig +++ b/src/components/comment/comment.twig @@ -43,7 +43,9 @@ message: 'This comment is awaiting moderation.' } only %} {% endif %} - {{comment.comment_content|raw}} + {% block comment_content %} + {{comment.comment_content|raw}} + {% endblock %} {% endblock %} {% endembed %}