From c60d46c68b24a33361793ca58cea50d45af4fedd Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Fri, 7 Jan 2022 12:51:03 +0100 Subject: [PATCH] put macro show_comment in a separate template --- .../Comment/index.html.twig | 41 ++----------------- .../Comment/macro_showItem.html.twig | 36 ++++++++++++++++ 2 files changed, 39 insertions(+), 38 deletions(-) create mode 100644 src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/Comment/macro_showItem.html.twig diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/Comment/index.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/Comment/index.html.twig index a45aef6bb..56dda187e 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/Comment/index.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/Comment/index.html.twig @@ -4,42 +4,7 @@ {{ 'Accompanying Course Comment list'|trans }} {% endblock %} -{% macro show_comment(comment, options) %} -
-
-
- {% if options.pinned is defined %} - - {% endif %} - - {{ 'by'|trans }}{{ comment.creator }}{{ ', ' ~ 'on'|trans ~ ' ' ~ comment.createdAt|format_date('long') }}
- {{ 'Last updated on'|trans ~ ' ' ~ comment.updatedAt|format_datetime('long', 'short') }} -
-
    - {% if options.pinned is not defined %} -
  • - -
  • - {% endif %} -
  • - -
  • -
  • - -
  • -
-
-
-
{{ comment.content|chill_markdown_to_html }}
-
-
-{% endmacro %} +{% import '@ChillPerson/AccompanyingCourse/Comment/macro_showItem.html.twig' as macro %} {% macro form_comment(type, form) %} {% if type == 'edit' %} @@ -73,14 +38,14 @@ {% if commentEditId == accompanyingCourse.pinnedComment.id %} {{ _self.form_comment('edit', edit_form) }} {% else %} - {{ _self.show_comment(accompanyingCourse.pinnedComment, {'pinned': 'true'}) }} + {{ macro.show_comment(accompanyingCourse.pinnedComment, {'pinned': 'true'}) }} {% endif %} {% endif %} {% for c in accompanyingCourse.comments %} {% if commentEditId == c.id %} {{ _self.form_comment('edit', edit_form) }} {% else %} - {{ _self.show_comment(c) }} + {{ macro.show_comment(c) }} {% endif %} {% endfor %} diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/Comment/macro_showItem.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/Comment/macro_showItem.html.twig new file mode 100644 index 000000000..82309300e --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/Comment/macro_showItem.html.twig @@ -0,0 +1,36 @@ +{% macro show_comment(comment, options) %} +
+
+
+ {% if options.pinned is defined %} + + {% endif %} + + {{ 'by'|trans }}{{ comment.creator }}{{ ', ' ~ 'on'|trans ~ ' ' ~ comment.createdAt|format_date('long') }}
+ {{ 'Last updated on'|trans ~ ' ' ~ comment.updatedAt|format_datetime('long', 'short') }} +
+
    + {% if options.pinned is not defined %} +
  • + +
  • + {% endif %} +
  • + +
  • +
  • + +
  • +
+
+
+
{{ comment.content|chill_markdown_to_html }}
+
+
+{% endmacro %}