Class: Stratus::Generator::LiquidContext

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

Overview

Liquid =

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeLiquidContext



8
9
10
11
12
# File 'lib/stratus/generator/context.rb', line 8

def initialize
  super
  self.merge!(self.class.site_data)
  self
end

Class Method Details

.path_to_rootObject



15
16
17
# File 'lib/stratus/generator/context.rb', line 15

def path_to_root
  @path_to_root ||= ''
end

.path_to_root=(path) ⇒ Object



18
19
20
# File 'lib/stratus/generator/context.rb', line 18

def path_to_root=(path)
  @path_to_root = path
end

.site_dataObject



22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/stratus/generator/context.rb', line 22

def site_data
  @site_data ||= returning({}) do |data|
    data['site'] = Stratus.settings['site']
    data['vars'] =Stratus.settings.fetch('vars', {})
    Stratus::Resources.collection_types.each do |col_type|
      sort_col = Stratus.content_setting(col_type, 'sort', 'index').to_sym
      reversed = Stratus.content_setting(col_type, 'reverse', false)
      collection_data = Stratus::Resources.content(:collection_type=>col_type, :sort_by=>sort_col, :reverse=>reversed)
      data[col_type] = collection_data
      data[col_type.singularize] = hashify(collection_data)
    end
  end
end