Skip to content

Commit 00d94c9

Browse files
committed
Merge pull request #73 from pathawks/liquid
Merge pull request 73
2 parents caa3bb5 + 27d0ff7 commit 00d94c9

File tree

4 files changed

+24
-28
lines changed

4 files changed

+24
-28
lines changed

lib/feed.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
{% endif %}
5050

5151
<id>{{ post.id | prepend: url_base | xml_escape }}</id>
52-
<content type="html" xml:base="{{ post.url | prepend: url_base | xml_escape }}">{{ post.content | markdownify | strip | xml_escape }}</content>
52+
<content type="html" xml:base="{{ post.url | prepend: url_base | xml_escape }}">{{ post.content | strip | xml_escape }}</content>
5353

5454
{% if post.author %}
5555
<author>
@@ -76,7 +76,7 @@
7676
{% endfor %}
7777

7878
{% if post.excerpt and post.excerpt != empty %}
79-
<summary>{{ post.excerpt | markdownify | strip_html | replace: '\n', ' ' | strip | xml_escape }}</summary>
79+
<summary>{{ post.excerpt | strip_html | replace: '\n', ' ' | strip | xml_escape }}</summary>
8080
{% endif %}
8181
</entry>
8282
{% endfor %}

lib/jekyll-feed.rb

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
require 'fileutils'
1+
require "fileutils"
22

33
module Jekyll
44
class PageWithoutAFile < Page
@@ -58,9 +58,7 @@ def generate(site)
5858
@site = site
5959
@site.config["time"] = Time.new
6060
unless feed_exists?
61-
write
62-
@site.keep_files ||= []
63-
@site.keep_files << path
61+
@site.pages << feed_content
6462
end
6563
end
6664

@@ -69,27 +67,13 @@ def source_path
6967
File.expand_path "feed.xml", File.dirname(__FILE__)
7068
end
7169

72-
# Destination for feed.xml file within the site source directory
73-
def destination_path
74-
if @site.respond_to?(:in_dest_dir)
75-
@site.in_dest_dir(path)
76-
else
77-
Jekyll.sanitized_path(@site.dest, path)
78-
end
79-
end
80-
81-
# copy feed template from source to destination
82-
def write
83-
FileUtils.mkdir_p File.dirname(destination_path)
84-
File.open(destination_path, 'w') { |f| f.write(feed_content) }
85-
end
86-
8770
def feed_content
88-
site_map = PageWithoutAFile.new(@site, File.dirname(__FILE__), "", path)
89-
site_map.content = File.read(source_path).gsub(/\s*\n\s*/, "\n").gsub(/\n{%/, "{%")
90-
site_map.data["layout"] = nil
91-
site_map.render(Hash.new, @site.site_payload)
92-
site_map.output
71+
feed = PageWithoutAFile.new(@site, File.dirname(__FILE__), "", path)
72+
feed.content = File.read(source_path).gsub(/\s*\n\s*/, "\n").gsub(/\s+{%/, "{%").gsub(/\s+</,"<")
73+
feed.data["layout"] = nil
74+
feed.data["sitemap"] = false
75+
feed.output
76+
feed
9377
end
9478

9579
# Checks if a feed already exists in the site source
@@ -107,4 +91,4 @@ def feed_exists?
10791
Liquid::Template.register_filter(Jekyll::StripWhitespace)
10892
end
10993

110-
Liquid::Template.register_tag('feed_meta', Jekyll::FeedMetaTag)
94+
Liquid::Template.register_tag("feed_meta", Jekyll::FeedMetaTag)
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
---
3+
4+
{% capture liquidstring %}
5+
Liquid is not rendered.
6+
{% endcapture %}
7+
{{ liquidstring | replace:'not ','' }}

spec/jekyll-feed_spec.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,11 @@
7676
expect(contents).to match /<title>The plugin will properly strip newlines.<\/title>/
7777
end
7878

79+
it "renders Liquid inside posts" do
80+
expect(contents).to match /Liquid is rendered\./
81+
expect(contents).not_to match /Liquid is not rendered\./
82+
end
83+
7984
context "parsing" do
8085
let(:feed) { RSS::Parser.parse(contents) }
8186

@@ -95,7 +100,7 @@
95100
end
96101

97102
it "includes the items" do
98-
expect(feed.items.count).to eql(7)
103+
expect(feed.items.count).to eql(8)
99104
end
100105

101106
it "includes item contents" do

0 commit comments

Comments
 (0)