Saturday 15 March 2014

liquid - Use jekyll variable inside replace filter -



liquid - Use jekyll variable inside replace filter -

i have rss template in jekyll below:

--- 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> {% 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>

now, want http://example.com (currently hard-coded) replaced {{ site.url }} variable. have tried numerous ways, unable accomplish it.

part of reply in question :

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

jekyll liquid

No comments:

Post a Comment