我尝试在 Symfony 项目中制作一个漂亮的 RSS Feed。对于每个项目,我包含一个文件。没关系,但是当我查看输出时,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>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>
Run Code Online (Sandbox Code Playgroud)
我该怎么做才能在“项目文件”中保持缩进而不出现错误的缩进?我尝试使用spaceless和-,但没有成功。
如果可以的话,这里是我的文件。
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 …Run Code Online (Sandbox Code Playgroud)