Class: Stachio::Template
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Stachio::Template
- Includes:
- ActiveModel::ForbiddenAttributesProtection
- Defined in:
- app/models/stachio/template.rb
Instance Attribute Summary collapse
-
#presents ⇒ Object
Returns the value of attribute presents.
-
#rendered ⇒ Object
Returns the value of attribute rendered.
Instance Method Summary collapse
- #describe(n = 32) ⇒ Object
- #present(values = nil, options = {}) ⇒ Object
- #render(options = {}) ⇒ Object (also: #assemble, #composite, #compose)
- #reset ⇒ Object
Instance Attribute Details
#presents ⇒ Object
Returns the value of attribute presents.
11 12 13 |
# File 'app/models/stachio/template.rb', line 11 def presents @presents end |
#rendered ⇒ Object
Returns the value of attribute rendered.
11 12 13 |
# File 'app/models/stachio/template.rb', line 11 def rendered @rendered end |
Instance Method Details
#describe(n = 32) ⇒ Object
32 33 34 |
# File 'app/models/stachio/template.rb', line 32 def describe(n=32) (description && description.size > n) ? description[0..n] + ' [...]' : description end |
#present(values = nil, options = {}) ⇒ Object
26 27 28 29 30 |
# File 'app/models/stachio/template.rb', line 26 def present(values=nil, ={}) return render if values.nil? self.presents = values render .merge(:force => true) end |
#render(options = {}) ⇒ Object Also known as: assemble, composite, compose
17 18 19 20 21 |
# File 'app/models/stachio/template.rb', line 17 def render(={}) = .with_indifferent_access reset if !!([:force] or [:reset]) self.rendered ||= Mustache.render(content, presents) unless presents.nil? end |
#reset ⇒ Object
13 14 15 |
# File 'app/models/stachio/template.rb', line 13 def reset self.rendered = nil end |