Chris@0
|
1 {#
|
Chris@0
|
2 /**
|
Chris@0
|
3 * @file
|
Chris@0
|
4 * Theme override for comments.
|
Chris@0
|
5 *
|
Chris@0
|
6 * Available variables:
|
Chris@0
|
7 * - author: Comment author. Can be a link or plain text.
|
Chris@0
|
8 * - content: The content-related items for the comment display. Use
|
Chris@0
|
9 * {{ content }} to print them all, or print a subset such as
|
Chris@0
|
10 * {{ content.field_example }}. Use the following code to temporarily suppress
|
Chris@0
|
11 * the printing of a given child element:
|
Chris@0
|
12 * @code
|
Chris@0
|
13 * {{ content|without('field_example') }}
|
Chris@0
|
14 * @endcode
|
Chris@0
|
15 * - created: Formatted date and time for when the comment was created.
|
Chris@18
|
16 * Preprocess functions can reformat it by calling DateFormatter::format()
|
Chris@18
|
17 * with the desired parameters on the 'comment.created' variable.
|
Chris@0
|
18 * - changed: Formatted date and time for when the comment was last changed.
|
Chris@18
|
19 * Preprocess functions can reformat it by calling DateFormatter::format()
|
Chris@18
|
20 * with the desired parameters on the 'comment.changed' variable.
|
Chris@0
|
21 * - permalink: Comment permalink.
|
Chris@0
|
22 * - submitted: Submission information created from author and created
|
Chris@0
|
23 * during template_preprocess_comment().
|
Chris@0
|
24 * - user_picture: The comment author's profile picture.
|
Chris@0
|
25 * - status: Comment status. Possible values are:
|
Chris@0
|
26 * unpublished, published, or preview.
|
Chris@0
|
27 * - title: Comment title, linked to the comment.
|
Chris@0
|
28 * - attributes: HTML attributes for the containing element.
|
Chris@0
|
29 * The attributes.class may contain one or more of the following classes:
|
Chris@0
|
30 * - comment: The current template type; e.g., 'theming hook'.
|
Chris@0
|
31 * - by-anonymous: Comment by an unregistered user.
|
Chris@0
|
32 * - by-{entity-type}-author: Comment by the author of the parent entity,
|
Chris@0
|
33 * eg. by-node-author.
|
Chris@0
|
34 * - preview: When previewing a new or edited comment.
|
Chris@0
|
35 * The following applies only to viewers who are registered users:
|
Chris@0
|
36 * - unpublished: An unpublished comment visible only to administrators.
|
Chris@0
|
37 * - title_prefix: Additional output populated by modules, intended to be
|
Chris@0
|
38 * displayed in front of the main title tag that appears in the template.
|
Chris@0
|
39 * - title_suffix: Additional output populated by modules, intended to be
|
Chris@0
|
40 * displayed after the main title tag that appears in the template.
|
Chris@0
|
41 * - content_attributes: List of classes for the styling of the comment content.
|
Chris@0
|
42 * - title_attributes: Same as attributes, except applied to the main title
|
Chris@0
|
43 * tag that appears in the template.
|
Chris@0
|
44 * - threaded: A flag indicating whether the comments are threaded or not.
|
Chris@0
|
45 *
|
Chris@0
|
46 * These variables are provided to give context about the parent comment (if
|
Chris@0
|
47 * any):
|
Chris@17
|
48 * - parent_comment: Full parent comment entity (if any).
|
Chris@0
|
49 * - parent_author: Equivalent to author for the parent comment.
|
Chris@0
|
50 * - parent_created: Equivalent to created for the parent comment.
|
Chris@0
|
51 * - parent_changed: Equivalent to changed for the parent comment.
|
Chris@0
|
52 * - parent_title: Equivalent to title for the parent comment.
|
Chris@0
|
53 * - parent_permalink: Equivalent to permalink for the parent comment.
|
Chris@0
|
54 * - parent: A text string of parent comment submission information created from
|
Chris@0
|
55 * 'parent_author' and 'parent_created' during template_preprocess_comment().
|
Chris@0
|
56 * This information is presented to help screen readers follow lengthy
|
Chris@0
|
57 * discussion threads. You can hide this from sighted users using the class
|
Chris@0
|
58 * visually-hidden.
|
Chris@0
|
59 *
|
Chris@0
|
60 * These two variables are provided for context:
|
Chris@0
|
61 * - comment: Full comment object.
|
Chris@0
|
62 * - entity: Entity the comments are attached to.
|
Chris@0
|
63 *
|
Chris@0
|
64 * @see template_preprocess_comment()
|
Chris@0
|
65 */
|
Chris@0
|
66 #}
|
Chris@0
|
67 {% if threaded %}
|
Chris@0
|
68 {{ attach_library('classy/indented') }}
|
Chris@0
|
69 {% endif %}
|
Chris@0
|
70 {%
|
Chris@0
|
71 set classes = [
|
Chris@0
|
72 'comment',
|
Chris@0
|
73 'js-comment',
|
Chris@0
|
74 status != 'published' ? status,
|
Chris@0
|
75 comment.owner.anonymous ? 'by-anonymous',
|
Chris@0
|
76 author_id and author_id == commented_entity.getOwnerId() ? 'by-' ~ commented_entity.getEntityTypeId() ~ '-author',
|
Chris@0
|
77 ]
|
Chris@0
|
78 %}
|
Chris@0
|
79 <article{{ attributes.addClass(classes) }}>
|
Chris@0
|
80 {#
|
Chris@0
|
81 Hide the "new" indicator by default, let a piece of JavaScript ask the
|
Chris@0
|
82 server which comments are new for the user. Rendering the final "new"
|
Chris@0
|
83 indicator here would break the render cache.
|
Chris@0
|
84 #}
|
Chris@0
|
85 <mark class="hidden" data-comment-timestamp="{{ new_indicator_timestamp }}"></mark>
|
Chris@0
|
86
|
Chris@0
|
87 <footer class="comment__meta">
|
Chris@0
|
88 {{ user_picture }}
|
Chris@0
|
89 <p class="comment__submitted">{{ submitted }}</p>
|
Chris@0
|
90
|
Chris@0
|
91 {#
|
Chris@0
|
92 Indicate the semantic relationship between parent and child comments for
|
Chris@0
|
93 accessibility. The list is difficult to navigate in a screen reader
|
Chris@0
|
94 without this information.
|
Chris@0
|
95 #}
|
Chris@0
|
96 {% if parent %}
|
Chris@0
|
97 <p class="parent visually-hidden">{{ parent }}</p>
|
Chris@0
|
98 {% endif %}
|
Chris@0
|
99
|
Chris@0
|
100 {{ permalink }}
|
Chris@0
|
101 </footer>
|
Chris@0
|
102
|
Chris@0
|
103 <div{{ content_attributes.addClass('content') }}>
|
Chris@0
|
104 {% if title %}
|
Chris@0
|
105 {{ title_prefix }}
|
Chris@0
|
106 <h3{{ title_attributes }}>{{ title }}</h3>
|
Chris@0
|
107 {{ title_suffix }}
|
Chris@0
|
108 {% endif %}
|
Chris@0
|
109 {{ content }}
|
Chris@0
|
110 </div>
|
Chris@0
|
111 </article>
|