在更换过滤器内使用jekyll变量
我在Jekyll中有一个RSS模板,如下所示:在更换过滤器内使用jekyll变量,jekyll,liquid,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
---
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>
---
布局:无
---
{{site.title}
{{site.time | date_to_xmlschema}}
{{site.url}/
{{site.author.name}
{{site.author.email}
{站点中的帖子的百分比。帖子限制:20%}
{{post.title}}
{{post.date | date_to_xmlschema}}
{{site.url}{{post.id}}
{post.content | replace:'src=“/assets','src=”http://example.com/assets“| xml_escape}”
{%endfor%}
现在,我想要
http://example.com
(当前硬编码)将替换为{{site.url}
变量。我已经尝试了很多方法,但都没有成功。部分答案来自以下问题:
{{ post.content | replace:'src="/assets','src="http://example.com/assets' | xml_escape | replace: 'http://example.com', site.url }}
请重读我的问题。url当前是硬编码的。我需要把它改成一个变量。谢谢你的回答,很抱歉投了反对票。