{#
/**
 * @file
 * Theme override to display an item in a views RSS feed.
 *
 * Available variables:
 * - title: RSS item title.
 * - link: RSS item link.
 * - description: RSS body text.
 * - item_elements: RSS item elements to be rendered as XML (pubDate, creator,
 *   guid).
 *
 * @see template_preprocess_views_view_row_rss()
 *
 * web/core/modules/node/src/Plugin/views/row/Rss.php manages to process the
 * node rendering without a node template being involved, and i'm not exactly
 * sure how, but we work around it by taking each field we enable in the RSS
 * Teaser view mode and overriding the field template, so go see various
 * field--*--rss-teaser.html.twig templates to see inside 'description'.
 */
#}
<item>
  <title>{{ title }}</title>
  <link>{{ link }}</link>
  <guid isPermaLink="true">{{ link }}</guid>
  {% for item in item_elements -%}
    {# The only Rss.php-provided element that we aren't overriding is pubDate #}
    {# TODO when online look up if there's an elegant way to filter a for loop #}
    {% if item.key == 'pubDate' %}
      <{{ item.key }}{{ item.attributes -}}
      {% if item.value -%}
        >{{ item.value }}</{{ item.key }}>
      {% else -%}
        {{ ' />' }}
      {% endif %}
    {% endif %}
  {%- endfor %}
  <comments>{{ link }}#comments</comments>
  {# The RSS Teaser view mode *must* be configured to output the body paragraph
     (summary) LAST; see below for why. #}
  {{ description|raw }}
  {{ '<p><a href="'|escape('html') }}{{ link }}{{ '">Read more and discuss at agaric.coop.</a></p>'|escape('html') }}
    {# Opening description tag is in paragraph template used for description,
       see field/field--field-body-paragraph--rss-teaser.html.twig and only the
       closing description tag is here so that we can have the read more link
       here (the node info isn't available in the paragraph field template, ugh.
       Also this is horrific and don't try this at home, kids. #}
    </description>
</item>
