From a312df8cda5115f4d97781366aaf48b083817c91 Mon Sep 17 00:00:00 2001
From: Alex Pott <alex.a.pott@googlemail.com>
Date: Fri, 24 May 2013 10:22:36 -0700
Subject: [PATCH] Issue #1843760 by webthingee, joelpittet, jpamental: Convert
 views/templates/views-view-rss.tpl.php to twig.

---
 .../views/templates/views-view-rss.html.twig  | 31 +++++++++++++++++++
 .../views/templates/views-view-rss.tpl.php    | 20 ------------
 core/modules/views/views.theme.inc            | 25 +++++++++------
 3 files changed, 47 insertions(+), 29 deletions(-)
 create mode 100644 core/modules/views/templates/views-view-rss.html.twig
 delete mode 100644 core/modules/views/templates/views-view-rss.tpl.php

diff --git a/core/modules/views/templates/views-view-rss.html.twig b/core/modules/views/templates/views-view-rss.html.twig
new file mode 100644
index 000000000000..d223b059cb2b
--- /dev/null
+++ b/core/modules/views/templates/views-view-rss.html.twig
@@ -0,0 +1,31 @@
+{#
+/**
+ * @file
+ * Default template for feed displays that use the RSS style.
+ *
+ * Available variables:
+ * - link: The link to the feed (the view path).
+ * - namespaces: The XML namespaces (added automatically).
+ * - title: The title of the feed (as set in the view).
+ * - description: The feed description (from feed settings).
+ * - langcode: The language encoding.
+ * - channel_elements: The formatted channel elements.
+ * - items: The feed items themselves.
+ *
+ * @see template_preprocess()
+ * @see template_preprocess_views_view_rss()
+ *
+ * @ingroup themeable
+ */
+#}
+<?xml version="1.0" encoding="utf-8" ?>
+<rss version="2.0" xml:base="{{ link }}"{{ namespaces }}>
+  <channel>
+    <title>{{ title }}</title>
+    <link>{{ link }}</link>
+    <description>{{ description }}</description>
+    <language>{{ langcode }}</language>
+    {{ channel_elements }}
+    {{ items }}
+  </channel>
+</rss>
diff --git a/core/modules/views/templates/views-view-rss.tpl.php b/core/modules/views/templates/views-view-rss.tpl.php
deleted file mode 100644
index 18ca73eaff64..000000000000
--- a/core/modules/views/templates/views-view-rss.tpl.php
+++ /dev/null
@@ -1,20 +0,0 @@
-<?php
-
-/**
- * @file
- * Default template for feed displays that use the RSS style.
- *
- * @ingroup views_templates
- */
-?>
-<?php print "<?xml"; ?> version="1.0" encoding="utf-8" <?php print "?>"; ?>
-<rss version="2.0" xml:base="<?php print $link; ?>"<?php print $namespaces; ?>>
-  <channel>
-    <title><?php print $title; ?></title>
-    <link><?php print $link; ?></link>
-    <description><?php print $description; ?></description>
-    <language><?php print $langcode; ?></language>
-    <?php print $channel_elements; ?>
-    <?php print $items; ?>
-  </channel>
-</rss>
diff --git a/core/modules/views/views.theme.inc b/core/modules/views/views.theme.inc
index e17f44f75604..d3c0a1346d1a 100644
--- a/core/modules/views/views.theme.inc
+++ b/core/modules/views/views.theme.inc
@@ -846,16 +846,22 @@ function template_preprocess_views_view_list(&$vars) {
 }
 
 /**
- * Preprocess an RSS feed
- */
+ * Prepares variables for RSS feed templates.
+ *
+ * Default template: views-view-rss.html.twig.
+ *
+ * @param array $vars
+ *   An associative array containing:
+ *   - view: A ViewExecutable object.
+ *   - rows: The raw row data.
+*/
 function template_preprocess_views_view_rss(&$vars) {
   global $base_url;
 
-  $view     = &$vars['view'];
-  $options  = &$vars['options'];
-  $items    = &$vars['rows'];
+  $view = $vars['view'];
+  $items = $vars['rows'];
 
-  $style    = &$view->style_plugin;
+  $style = $view->style_plugin;
 
   $config = config('system.site');
 
@@ -875,8 +881,8 @@ function template_preprocess_views_view_rss(&$vars) {
   }
   $vars['title'] = check_plain($title);
 
-  // Figure out which display which has a path we're using for this feed. If there isn't
-  // one, use the global $base_url
+  // Figure out which display which has a path we're using for this feed. If
+  // there isn't one, use the global $base_url
   $link_display_id = $view->display_handler->getLinkDisplay();
   if ($link_display_id && $display = $view->displayHandlers->get($link_display_id)) {
     $path = $view->displayHandlers->get($link_display_id)->getPath();
@@ -889,7 +895,8 @@ function template_preprocess_views_view_rss(&$vars) {
       $url_options['query'] = $view->exposed_raw_input;
     }
 
-    // Compare the link to the default home page; if it's the default home page, just use $base_url.
+    // Compare the link to the default home page; if it's the default home page,
+    // just use $base_url.
     if ($path == $config->get('page.front')) {
       $path = '';
     }
-- 
GitLab