Class: PufferPages::Liquid::Tags::Include

Inherits:
Liquid::Include
  • Object
show all
Defined in:
lib/puffer_pages/liquid/tags/include.rb

Direct Known Subclasses

Partials

Instance Method Summary collapse

Instance Method Details

#render(context) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/puffer_pages/liquid/tags/include.rb', line 6

def render(context)
  source = _read_template_from_file_system(context)
  variable = context[@variable_name || @template_name[1..-2]]

  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[1..-2]] = variable
        source.render(context)
      end
    else
      context[@template_name[1..-2]] = variable
      source.render(context)
    end
  end
end