Class: Orthor::Templates

Inherits:
Object
  • Object
show all
Defined in:
lib/orthor/templates.rb

Defined Under Namespace

Classes: Unknown

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.mappingsObject

Returns the value of attribute mappings.



6
7
8
# File 'lib/orthor/templates.rb', line 6

def mappings
  @mappings
end

.templatesObject

Returns the value of attribute templates.



6
7
8
# File 'lib/orthor/templates.rb', line 6

def templates
  @templates
end

Class Method Details

.[](key) ⇒ Object



22
23
24
25
# File 'lib/orthor/templates.rb', line 22

def self.[](key)
  self.templates ||= {}
  self.templates[key.to_s]
end

.define(&blk) ⇒ Object



9
10
11
12
# File 'lib/orthor/templates.rb', line 9

def self.define(&blk)
  self.templates, self.mappings = {}, {}
  class_eval &blk
end

.mapping(name, map) ⇒ Object



18
19
20
# File 'lib/orthor/templates.rb', line 18

def self.mapping(name, map)
  self.mappings[name] = map
end

.render(items, template_name_or_mapping) ⇒ Object



27
28
29
30
31
32
33
34
# File 'lib/orthor/templates.rb', line 27

def self.render(items, template_name_or_mapping)
  return items unless template_name_or_mapping

  items = [items] unless items.is_a?(Array)
  items.inject("") do |html, item|
    html += parse(item, template_name_or_mapping)
  end
end

.template(name, markup) ⇒ Object



14
15
16
# File 'lib/orthor/templates.rb', line 14

def self.template(name, markup)
  self.templates[name.to_s] = markup
end