diff --git a/core/modules/comment/comment.api.php b/core/modules/comment/comment.api.php
index 793d9ad6373382401715c3c2f8b7d6262b91e050..a27899e7755a0e0d468291fd8408da4219313f12 100644
--- a/core/modules/comment/comment.api.php
+++ b/core/modules/comment/comment.api.php
@@ -113,8 +113,7 @@ function hook_comment_view(\Drupal\comment\Plugin\Core\Entity\Comment $comment,
* If the module wishes to act on the rendered HTML of the comment rather than
* the structured content array, it may use this hook to add a #post_render
* callback. Alternatively, it could also implement hook_preprocess_HOOK() for
- * comment.tpl.php. See drupal_render() and theme() documentation respectively
- * for details.
+ * comment.html.twig. See drupal_render() documentation for details.
*
* @param $build
* A renderable array representing the comment.
diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module
index 0c2cd55a1c40a0998a289dc2ecc6059170af205c..807b672c7fa59d80f26f56536052d3adc2215e96 100644
--- a/core/modules/comment/comment.module
+++ b/core/modules/comment/comment.module
@@ -1553,9 +1553,14 @@ function comment_prepare_author(Comment $comment) {
}
/**
- * Preprocesses variables for comment.tpl.php.
+ * Prepares variables for comment templates.
*
- * @see comment.tpl.php
+ * Default template: comment.html.twig.
+ *
+ * @param array $variables
+ * An associative array containing:
+ * - elements: An associative array containing the comment and node objects.
+ * Array keys: #comment, #node.
*/
function template_preprocess_comment(&$variables) {
$comment = $variables['elements']['#comment'];
@@ -1564,6 +1569,7 @@ function template_preprocess_comment(&$variables) {
$variables['node'] = $node;
$account = comment_prepare_author($comment);
+ // @todo Do not call theme() here. We do this for purposes of t().
$variables['author'] = theme('username', array('account' => $account));
$variables['new'] = $comment->new->value ? t('new') : '';
$variables['created'] = format_date($comment->created->value);
@@ -1583,6 +1589,7 @@ function template_preprocess_comment(&$variables) {
else {
$variables['user_picture'] = array();
}
+
if (config('user.settings')->get('signatures') && !empty($account->signature)) {
$variables['signature'] = check_markup($account->signature, $account->signature_format, '', TRUE) ;
}
@@ -1602,6 +1609,7 @@ function template_preprocess_comment(&$variables) {
$comment_parent = $comment->pid->entity;
$account_parent = comment_prepare_author($comment_parent);
$variables['parent_comment'] = $comment_parent;
+ // @todo Do not call theme() here. We do this for purposes of t().
$variables['parent_author'] = theme('username', array('account' => $account_parent));
$variables['parent_created'] = format_date($comment_parent->created->value);
// Avoid calling format_date() twice on the same timestamp.
@@ -1664,6 +1672,10 @@ function template_preprocess_comment(&$variables) {
$variables['attributes']['class'][] = 'by-viewer';
}
}
+ // Add clearfix class.
+ $variables['attributes']['class'][] = 'clearfix';
+
+ $variables['content_attributes']['class'][] = 'content';
}
/**
@@ -1714,19 +1726,31 @@ function theme_comment_post_forbidden($variables) {
}
/**
- * Preprocesses variables for comment-wrapper.tpl.php.
+ * Prepares variables for comment wrapper templates.
+ *
+ * Default template: comment-wrapper.html.twig.
*
- * @see comment-wrapper.tpl.php
+ * @param array $variables
+ * An associative array containing:
+ * - content: An associative array containing render arrays for the list of
+ * comments, and the comment form. Array keys: comments, comment_form.
*/
function template_preprocess_comment_wrapper(&$variables) {
// Provide contextual information.
$variables['node'] = $variables['content']['#node'];
$variables['display_mode'] = variable_get('comment_default_mode_' . $variables['node']->type, COMMENT_MODE_THREADED);
+
// The comment form is optional and may not exist.
$variables['content'] += array('comment_form' => array());
+ $variables['attributes']['id'] = 'comments';
+
// Add a comment wrapper class.
$variables['attributes']['class'][] = 'comment-wrapper';
+
+ // Create separate variables for the comments and comment form.
+ $variables['comments'] = $variables['content']['comments'];
+ $variables['form'] = $variables['content']['comment_form'];
}
/**
diff --git a/core/modules/comment/templates/comment-wrapper.html.twig b/core/modules/comment/templates/comment-wrapper.html.twig
new file mode 100644
index 0000000000000000000000000000000000000000..dbf37cd9030c3abd7b868cf0f92bca24998d75cb
--- /dev/null
+++ b/core/modules/comment/templates/comment-wrapper.html.twig
@@ -0,0 +1,53 @@
+{#
+/**
+ * @file
+ * Default theme implementation for a comments container.
+ *
+ * Available variables:
+ * - comments: List of comments rendered through comment.html.twig.
+ * - form: The 'Add new comment' form.
+ * - content: The content-related elements for the comment display. Use
+ * 'content' to print them all, or print a subset such as
+ * 'content.comment_form'.
+ * - attributes: Remaining HTML attributes for the containing element.
+ * It includes the 'class' information, which includes:
+ * - comment-wrapper: The current template type, i.e., "theming hook".
+ * - title_prefix: Additional output populated by modules, intended to be
+ * displayed in front of the main title tag that appears in the template.
+ * - title_suffix: Additional title output populated by modules, intended to
+ * be displayed after the main title tag that appears in the template.
+ *
+ * The following variables are provided for contextual information.
+ * - node: The node entity to which the comments belong.
+ * - display_mode: The display mode for the comment listing, flat or threaded.
+ * The constants below show the possible values and should be used for
+ * comparison, as in the following example:
+ * @code
+ * {% if display_mode is constant('COMMENT_MODE_THREADED') %}
+ *
{{ 'These comments are displayed in a threaded list.'|t }}
+ {{ title_suffix }}
+ {% endif %}
+
+ {{ comments }}
+
+ {% if form %}
+
{{ 'Add new comment'|t }}
+ {{ form }}
+ {% endif %}
+
+
diff --git a/core/modules/comment/templates/comment-wrapper.tpl.php b/core/modules/comment/templates/comment-wrapper.tpl.php
deleted file mode 100644
index ac1c27f94f99297c67afd249e275598fdc49af15..0000000000000000000000000000000000000000
--- a/core/modules/comment/templates/comment-wrapper.tpl.php
+++ /dev/null
@@ -1,48 +0,0 @@
-
->
- type != 'forum'): ?>
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/core/modules/comment/templates/comment.html.twig b/core/modules/comment/templates/comment.html.twig
new file mode 100644
index 0000000000000000000000000000000000000000..4b441dd24ef19c68a7f7601b00163379d884b64c
--- /dev/null
+++ b/core/modules/comment/templates/comment.html.twig
@@ -0,0 +1,106 @@
+{#
+/**
+ * @file
+ * Default theme implementation for comments.
+ *
+ * Available variables:
+ * - author: Comment author. Can be a link or plain text.
+ * - content: The content-related items for the comment display. Use
+ * {{ content }} to print them all, or print a subset such as
+ * {{ content.field_example }}. Use hide(content.field_example) to temporarily
+ * suppress the printing of a given element.
+ * - created: Formatted date and time for when the comment was created.
+ * Preprocess functions can reformat it by calling format_date() with the
+ * desired parameters on the 'comment.created' variable.
+ * - changed: Formatted date and time for when the comment was last changed.
+ * Preprocess functions can reformat it by calling format_date() with the
+ * desired parameters on the 'comment.changed' variable.
+ * - new: New comment marker.
+ * - permalink: Comment permalink.
+ * - submitted: Submission information created from author and created
+ * during template_preprocess_comment().
+ * - user_picture: The comment author's profile picture.
+ * - signature: The comment author's signature.
+ * - status: Comment status. Possible values are:
+ * unpublished, published, or preview.
+ * - title: Comment title, linked to the comment.
+ * - attributes.class: List of classes that can be used to style contextually
+ * through CSS. The default values can be one or more of the following:
+ * - comment: The current template type; e.g., 'theming hook'.
+ * - by-anonymous: Comment by an unregistered user.
+ * - by-node-author: Comment by the author of the parent node.
+ * - preview: When previewing a new or edited comment.
+ * The following applies only to viewers who are registered users:
+ * - unpublished: An unpublished comment visible only to administrators.
+ * - by-viewer: Comment by the user currently viewing the page.
+ * - new: New comment since the last visit.
+ * - title_prefix: Additional output populated by modules, intended to be
+ * displayed in front of the main title tag that appears in the template.
+ * - title_suffix: Additional output populated by modules, intended to be
+ * displayed after the main title tag that appears in the template.
+ * - content_attributes: List of classes for the styling of the comment content.
+ *
+ * These variables are provided to give context about the parent comment (if
+ * any):
+ * - comment_parent: Full parent comment entity (if any).
+ * - parent_author: Equivalent to author for the parent comment.
+ * - parent_created: Equivalent to created for the parent comment.
+ * - parent_changed: Equivalent to changed for the parent comment.
+ * - parent_title: Equivalent to title for the parent comment.
+ * - parent_permalink: Equivalent to permalink for the parent comment.
+ * - parent: A text string of parent comment submission information created from
+ * 'parent_author' and 'parent_created' during template_preprocess_comment().
+ * This information is presented to help screen readers follow lengthy
+ * discussion threads. You can hide this from sighted users using the class
+ * element-invisible.
+ *
+ * These two variables are provided for context:
+ * - comment: Full comment object.
+ * - node: Node entity the comments are attached to.
+ *
+ * @see template_preprocess()
+ * @see template_preprocess_comment()
+ *
+ * @ingroup themeable
+ */
+#}
+
+ {{ title_prefix }}
+
+ {% if new %}
+ {{ new }}
+ {% endif %}
+
+
{{ title }}
+
+ {{ title_suffix }}
+
+
+
+
+ {# We hide the links now so that we can render them later. #}
+ {% hide(content.links) %}
+ {{ content }}
+
+ {% if signature %}
+
+ {{ signature }}
+
+ {% endif %}
+
+ {{ content.links }}
+
diff --git a/core/modules/comment/templates/comment.tpl.php b/core/modules/comment/templates/comment.tpl.php
deleted file mode 100644
index 5a8a37e50284c1b64345b2d736edbaa35ec2dc3a..0000000000000000000000000000000000000000
--- a/core/modules/comment/templates/comment.tpl.php
+++ /dev/null
@@ -1,110 +0,0 @@
-created variable.
- * - $changed: Formatted date and time for when the comment was last changed.
- * Preprocess functions can reformat it by calling format_date() with the
- * desired parameters on the $comment->changed variable.
- * - $new: New comment marker.
- * - $permalink: Comment permalink.
- * - $submitted: Submission information created from $author and $created during
- * template_preprocess_comment().
- * - $user_picture: The comment author's picture. Use render($user_picture) to
- * print it.
- * - $signature: Authors signature.
- * - $status: Comment status. Possible values are:
- * unpublished, published, or preview.
- * - $title: Linked title.
- * - $attributes: An instance of Attributes class that can be manipulated as an
- * array and printed as a string.
- * It includes the 'class' information, which includes:
- * - comment: The current template type; e.g., 'theming hook'.
- * - by-anonymous: Comment by an unregistered user.
- * - by-node-author: Comment by the author of the parent node.
- * - preview: When previewing a new or edited comment.
- * The following applies only to viewers who are registered users:
- * - unpublished: An unpublished comment visible only to administrators.
- * - by-viewer: Comment by the user currently viewing the page.
- * - new: New comment since the last visit.
- * - $title_prefix (array): An array containing additional output populated by
- * modules, intended to be displayed in front of the main title tag that
- * appears in the template.
- * - $title_suffix (array): An array containing additional output populated by
- * modules, intended to be displayed after the main title tag that appears in
- * the template.
- *
- * These variables are provided to give context about the parent comment (if
- * any):
- * - $comment_parent: Full parent comment object (if any).
- * - $parent_author: Equivalent to $author for the parent comment.
- * - $parent_created: Equivalent to $created for the parent comment.
- * - $parent_changed: Equivalent to $changed for the parent comment.
- * - $parent_title: Equivalent to $title for the parent comment.
- * - $parent_permalink: Equivalent to $permalink for the parent comment.
- * - $parent: A text string of parent comment submission information created
- * from $parent_author and $parent_created during
- * template_preprocess_comment(). This information is presented to help
- * screen readers follow lengthy discussion threads. You can hide this from
- * sighted users using the class element-invisible.
- *
- * These two variables are provided for context:
- * - $comment: Full comment object.
- * - $node: Node entity the comments are attached to.
- *
- * @see template_preprocess()
- * @see template_preprocess_comment()
- * @see template_process()
- * @see theme_comment()
- *
- * @ingroup themeable
- */
-?>
->
-
-
-
-
-
-
>
-
-
-
-
-
>
-
-
-
-
-
-
-
-
-
-
diff --git a/core/modules/rdf/rdf.module b/core/modules/rdf/rdf.module
index a2f74a33e8780894ed08463b81ffbc3588e31d41..3783f6bcaadcce310f9f094d0dd86b9ee977ded3 100644
--- a/core/modules/rdf/rdf.module
+++ b/core/modules/rdf/rdf.module
@@ -701,7 +701,7 @@ function rdf_preprocess_username(&$variables) {
}
/**
- * Implements hook_preprocess_HOOK() for comment.tpl.php.
+ * Implements hook_preprocess_HOOK() for comment.html.twig.
*/
function rdf_preprocess_comment(&$variables) {
$comment = $variables['comment'];
@@ -848,7 +848,7 @@ function rdf_preprocess_image(&$variables) {
* - variable_name: The name of the variable by which the template will
* refer to this content. Each template file has documentation about
* the variables it uses. For example, if this function is called in
- * preparing the $author variable for comment.tpl.php, then the
+ * preparing the $author variable for comment.html.twig, then the
* 'variable_name' is 'author'.
* - variables: The full array of variables about to be passed to the
* template.