I try to make a pretty RSS Feed in a Symfony project. For each item, I include one file. It's ok but when I look the output, Twig reset indentation in the block element. Here an example :
<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
>
<channel>
<title>Space Raclette</title>
<description></description>
<language>fr</language>
<lastBuildDate>Wed, 30 Nov 2016 11:22:45 +0100</lastBuildDate>
<item>
<title>Topic de l'ƩtƩ du Capitaine Crochet 2</title>
<link>...</link>
<guid isPermaLink="false">.../39fa</guid>
<description></description>
</item>
<item>
<title>Topic de l'ƩtƩ du Capitaine Crochet</title>
<link>...</link>
<guid isPermaLink="false">.../39fa</guid>
<description></description>
</item>
</channel>
</rss>
What can I do to keep the indentation without have bad indentation in the "item file" ? I tried to play with spaceless
and -
, without success.
Here my files if it can help.
layout.rss.twig :
<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
>
<channel>
<title>{{ channel.brand }}</title>
<atom:link href="{{ app.request.uri }}" rel="self" type="application/rss+xml" />
<link>{{ url }}</link>
<description>{{ channel.description|striptags }}</description>
<language>{{ channel.lang }}</language>
<lastBuildDate>{{ last_publication.published|date('D, d M Y H:i:s O') }}</lastBuildDate>
{% block content %}{% endblock %}
</channel>
</rss>
index.rss.twig
{% extends 'RSSBundle::layout.rss.twig' %}
{% block content %}
{% for publication in web_publications %}
{{ include('RSSBundle:Publication:_single.rss.twig') }}
{% endfor %}
{% endblock %}
_single.rss.twig
<item>
<title>{{ publication.title }}</title>
<link>{{ url }}</link>
<description></description>
<pubDate>{{ publication.published|date('D, d M Y H:i:s O') }}</pubDate>
</item>