私はかなりのRSSフィードをSymfonyプロジェクトで作成しようとしています。各項目には、1つのファイルが含まれています。 OKですが、出力を見ると、ブロック要素の字幕が字下げをリセットします。ここに例を示します: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>
「アイテムファイル」にインデントを残さずにインデントを維持するにはどうすればよいですか? 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 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>
「視覚的に」必要な空白か、ソースコード内にスペース(インデント)を入れたいですか(ブラウザのソースを表示しますか?) –
@ AlvinBunk私たちはXMLフィードに入っているので、この場合も同じです。しかし、それはソースコード用です。 –
これは痛みになります。 rssを入力として受け取り、美しいrssを出力として返す関数を作成する方がよいでしょう。例: '{{beautify_xml(include(" hello.rss.twig ")}}}'ここで 'beautify_xml'は[this implementation](http://stackoverflow.com/a/3616722/)のtwig拡張になります。 731138)。あなたのコメントのために –