Sha256: 90ffbd2e60109a5c2c9b01c23942b3d5b2b04f3cb66a8830b63469d7c74a087d

Contents?: true

Size: 1.09 KB

Versions: 29

Compression:

Stored size: 1.09 KB

Contents

# a modified include tag from the default liquid one
# includes content from oather page neames

module Liquid
  class Include < Liquid::Tag
    def render(context)
      template_name = context[@template_name]
      raise FileSystemError, "Illegal page template name '#{template_name}'" unless template_name =~ Cms::Page::NAME_REGEX

      page = context.registers[:context].pages.find_by_name(template_name)
      raise FileSystemError, "No such page template '#{template_name}'" if page.nil?
      
      source  = page.content
      partial = Liquid::Template.parse(source)

      variable = context[@variable_name || template_name]

      context.stack do
        @attributes.each do |key, value|
          context[key] = context[value]
        end

        if variable.is_a?(Array)
          
          variable.collect do |variable|            
            context[template_name] = variable
            partial.render(context)
          end

        else
                    
          context[template_name] = variable
          partial.render(context)
          
        end
      end
    end
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
liquid_cms-0.3.2.0 app/liquid/tags/cms_include_tag.rb
liquid_cms-0.2.2.0 app/liquid/tags/cms_include_tag.rb
liquid_cms-0.2.1.1 app/liquid/tags/cms_include_tag.rb
liquid_cms-0.3.1.0 app/liquid/tags/cms_include_tag.rb
liquid_cms-0.2.1.0 app/liquid/tags/cms_include_tag.rb
liquid_cms-0.2.0.13 app/liquid/tags/cms_include_tag.rb
liquid_cms-0.3.0.10 app/liquid/tags/cms_include_tag.rb
liquid_cms-0.3.0.9 app/liquid/tags/cms_include_tag.rb
liquid_cms-0.2.0.12 app/liquid/tags/cms_include_tag.rb
liquid_cms-0.2.0.11 app/liquid/tags/cms_include_tag.rb
liquid_cms-0.2.0.10 app/liquid/tags/cms_include_tag.rb
liquid_cms-0.3.0.8 app/liquid/tags/cms_include_tag.rb
liquid_cms-0.2.0.9 app/liquid/tags/cms_include_tag.rb
liquid_cms-0.3.0.7 app/liquid/tags/cms_include_tag.rb
liquid_cms-0.3.0.6 app/liquid/tags/cms_include_tag.rb
liquid_cms-0.2.0.8 app/liquid/tags/cms_include_tag.rb
liquid_cms-0.3.0.5 app/liquid/tags/cms_include_tag.rb
liquid_cms-0.2.0.7 app/liquid/tags/cms_include_tag.rb
liquid_cms-0.3.0.4 app/liquid/tags/cms_include_tag.rb
liquid_cms-0.2.0.6 app/liquid/tags/cms_include_tag.rb