2010-08-08 11:30:27 +00:00
|
|
|
module Locomotive
|
|
|
|
module Liquid
|
|
|
|
module Tags
|
2010-08-20 00:31:01 +00:00
|
|
|
class Extends < ::Liquid::Extends
|
2010-08-08 11:30:27 +00:00
|
|
|
|
2010-08-20 00:31:01 +00:00
|
|
|
def parse_parent_template(context)
|
2010-08-21 23:56:44 +00:00
|
|
|
page = nil
|
|
|
|
|
|
|
|
if @template_name == 'parent'
|
|
|
|
page = context[:page].parent
|
|
|
|
else
|
|
|
|
page = context[:site].pages.where(:fullpath => @template_name.gsub("'", '')).first
|
|
|
|
end
|
2010-08-08 11:30:27 +00:00
|
|
|
|
2010-08-20 00:31:01 +00:00
|
|
|
raise PageNotFound.new("Page with fullpath '#{@template_name}' was not found") if page.nil?
|
2010-08-08 11:30:27 +00:00
|
|
|
|
2010-08-20 00:31:01 +00:00
|
|
|
template = page.template
|
2010-08-08 11:30:27 +00:00
|
|
|
|
2010-08-20 00:31:01 +00:00
|
|
|
# merge blocks ?
|
|
|
|
blocks = find_blocks(template.root.nodelist)
|
2010-08-08 11:30:27 +00:00
|
|
|
|
2010-08-20 00:31:01 +00:00
|
|
|
blocks.each_value do |block|
|
|
|
|
block.send(:instance_variable_set, :"@context", context)
|
|
|
|
block.end_tag
|
2010-08-08 11:30:27 +00:00
|
|
|
end
|
|
|
|
|
2010-08-20 00:31:01 +00:00
|
|
|
template
|
2010-08-08 11:30:27 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
::Liquid::Template.register_tag('extends', Extends)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|