在替换过滤器中使用jekyll变量

时间:2014-10-17 16:54:05

标签: jekyll liquid

我在Jekyll有一个RSS模板,如下所示:

---
layout: nil
---
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
 <title>{{ site.title }}</title>
 <link href="{{ site.url }}/feed.atom" rel="self"/>
 <link href="{{ site.url }}/"/>
 <updated>{{ site.time | date_to_xmlschema }}</updated>
 <id>{{ site.url }}/</id>
 <author>
   <name>{{ site.author.name }}</name>
   <email>{{ site.author.email }}</email>
 </author>
 {% for post in site.posts limit:20 %}
 <entry>
   <title>{{ post.title }}</title>
   <link href="{{ site.url }}{{ post.url }}"/>
   <updated>{{ post.date | date_to_xmlschema }}</updated>
   <id>{{ site.url }}{{ post.id }}</id>
   <content type="html">{{ post.content | replace:'src="/assets','src="http://example.com/assets' | xml_escape }}</content>
 </entry>
 {% endfor %}
</feed>

现在,我希望将http://example.com(当前是硬编码的)替换为{{ site.url }}变量。我尝试了很多方法,但我无法实现它。

1 个答案:

答案 0 :(得分:2)

部分答案在于问题:

{{ post.content | replace:'src="/assets','src="http://example.com/assets' | xml_escape | replace: 'http://example.com', site.url }}
相关问题