Skip to content

Commit

Permalink
avoid infinite recursion while rendering layouts
Browse files Browse the repository at this point in the history
  • Loading branch information
tmm1 committed May 23, 2011
1 parent f808c98 commit 22585d4
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lib/jekyll/convertible.rb
@@ -1,3 +1,5 @@
require 'set'

# Convertible provides methods for converting a pagelike item
# from a certain type of markup into actual content
#
Expand Down Expand Up @@ -86,6 +88,8 @@ def do_layout(payload, layouts)

# recursively render layouts
layout = layouts[self.data["layout"]]
used = Set.new([layout])

while layout
payload = payload.deep_merge({"content" => self.output, "page" => layout.data})

Expand All @@ -95,7 +99,13 @@ def do_layout(payload, layouts)
puts "Liquid Exception: #{e.message} in #{self.data["layout"]}"
end

layout = layouts[layout.data["layout"]]
if layout = layouts[layout.data["layout"]]
if used.include?(layout)
layout = nil # avoid recursive chain
else
used << layout
end
end
end
end
end
Expand Down

0 comments on commit 22585d4

Please sign in to comment.