Module: Roda::RodaPlugins::Inversion::ClassMethods

Defined in:
lib/roda/plugins/inversion.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#layout_templateObject

An optional layout/wrap template.



117
118
119
# File 'lib/roda/plugins/inversion.rb', line 117

def layout_template
  @layout_template
end

#template_mapObject (readonly)

The map of template names to template file paths.



114
115
116
# File 'lib/roda/plugins/inversion.rb', line 114

def template_map
  @template_map
end

Class Method Details

.extended(subclass) ⇒ Object

Add this Gem’s template location to the Inversion search path.



105
106
107
108
109
110
# File 'lib/roda/plugins/inversion.rb', line 105

def self::extended( subclass )
  subclass.instance_variable_set( :@template_map, {} )
  subclass.instance_variable_set( :@layout_template, nil )

  super
end

Instance Method Details

#layout(tmpl) ⇒ Object

Load an Inversion::Template for the layout template.



134
135
136
137
138
# File 'lib/roda/plugins/inversion.rb', line 134

def layout( tmpl )
  enc = Encoding.default_internal || Encoding::UTF_8
  self.layout_template = ::Inversion::Template.load( tmpl, encoding: enc )
  return self.layout_template
end

#templates(hash) ⇒ Object

Load instances for all the template paths specified in the App’s class and return them in a hash keyed by name (Symbol).



122
123
124
125
126
127
128
129
130
# File 'lib/roda/plugins/inversion.rb', line 122

def templates( hash )
  @template_map = hash.each_with_object( {} ) do |(name, path), map|
    enc = Encoding.default_internal || Encoding::UTF_8
    map[ name ] = ::Inversion::Template.load( path, encoding: enc )
    map
  end

  return self.template_map
end