Sha256: 95625e2c064f166e370676ba92e7b2a973fd70497e07fc0ea095356b471b1b2d
Contents?: true
Size: 1.76 KB
Versions: 1
Compression:
Stored size: 1.76 KB
Contents
module Locomotive module Liquid module Tags class Extends < ::Liquid::Extends def prepare_parsing super parent_page = @context[:parent_page] @context[:page].merge_editable_elements_from_page(parent_page) @context[:snippets] = parent_page.snippet_dependencies @context[:templates] = ([*parent_page.template_dependencies] + [parent_page.id]).compact end private def parse_parent_template if @template_name == 'parent' if @context[:cached_parent] @context[:parent_page] = @context[:cached_parent] #.clone # parent must not be modified @context[:cached_parent].instance_variable_set(:@template, nil) # force to reload the template @context[:cached_parent] = nil else @context[:parent_page] = @context[:page].parent end else locale = ::Mongoid::Fields::I18n.locale @context[:parent_page] = @context[:cached_pages].try(:[], @template_name) || @context[:site].pages.where("fullpath.#{locale}" => @template_name).first end raise PageNotFound.new("Page with fullpath '#{@template_name}' was not found") if @context[:parent_page].nil? # be sure to work with a copy of the parent template otherwise there will be conflicts parent_template = @context[:parent_page].template.try(:clone) raise PageNotTranslated.new("Page with fullpath '#{@template_name}' was not translated") if parent_template.nil? @context[:parent_page].instance_variable_set(:@template, parent_template) parent_template end end ::Liquid::Template.register_tag('extends', Extends) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
locomotive_cms-2.0.0.rc7 | lib/locomotive/liquid/tags/extends.rb |