Class: Orthor::Templates
- Inherits:
-
Object
- Object
- Orthor::Templates
- Defined in:
- lib/orthor/templates.rb
Defined Under Namespace
Classes: Unknown
Class Attribute Summary collapse
-
.mappings ⇒ Object
Returns the value of attribute mappings.
-
.templates ⇒ Object
Returns the value of attribute templates.
Class Method Summary collapse
- .[](key) ⇒ Object
- .define(&blk) ⇒ Object
- .mapping(name, map) ⇒ Object
- .render(items, template_name_or_mapping) ⇒ Object
- .template(name, markup) ⇒ Object
Class Attribute Details
.mappings ⇒ Object
Returns the value of attribute mappings.
6 7 8 |
# File 'lib/orthor/templates.rb', line 6 def mappings @mappings end |
.templates ⇒ Object
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 |