Class: Stratus::Generator::LiquidRenderer

Inherits:
Object
  • Object
show all
Defined in:
lib/stratus/generator/renderer.rb

Overview

Liquid =

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeLiquidRenderer

Returns a new instance of LiquidRenderer.



10
11
12
# File 'lib/stratus/generator/renderer.rb', line 10

def initialize
  @context = LiquidContext.new
end

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.



8
9
10
# File 'lib/stratus/generator/renderer.rb', line 8

def context
  @context
end

Instance Method Details

#render_content(content, path_to_root = '../..') ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/stratus/generator/renderer.rb', line 14

def render_content(content, path_to_root='../..')
  in_context do
    context['this'] = content
    template = template_for(content.collection_type, 'content')
    context['content'] = parser_for(template).render(context, [Stratus::Filters])
    layout = layout_for(template)
    output = if layout.nil?
      context['content']
    else
      parser_for(layout).render(context, [Stratus::Filters])
    end
    fixup_paths(output, path_to_root)
  end
end

#render_index_for(collection_type, state = 'list') ⇒ Object

Currently unused… def render_content_fragment(content, state=nil)

in_context do
  context['this'] = content
  template = template_for(content.collection_type, state)
  output = parser_for(template).render(context, [Stratus::Filters])
  fixup_paths(output, ')
end

end



39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/stratus/generator/renderer.rb', line 39

def render_index_for(collection_type, state='list')
  in_context do
    template = template_for(collection_type, state)
    context['content'] = parser_for(template).render(context, [Stratus::Filters])
    layout = layout_for(template)
    output = if layout.nil?
      context['content']
    else
      output = parser_for(layout).render(context, [Stratus::Filters])
    end
    fixup_paths(output, (state.nil? ? '.' : '..'))
  end
end