Class: Pancake::Mixins::Render::Template
- Defined in:
- lib/pancake/mixins/render/template.rb
Defined Under Namespace
Classes: NotFound, UnamedTemplate
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#owner ⇒ Object
readonly
Returns the value of attribute owner.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#renderer ⇒ Object
readonly
Returns the value of attribute renderer.
Instance Method Summary collapse
-
#initialize(name, owner, path) ⇒ Template
constructor
A new instance of Template.
- #render(context = ViewContext.new, opts = {}) ⇒ Object
Constructor Details
#initialize(name, owner, path) ⇒ Template
Returns a new instance of Template.
10 11 12 13 14 15 |
# File 'lib/pancake/mixins/render/template.rb', line 10 def initialize(name, owner, path) @name, @owner, @path = name, owner, path raise UnamedTemplate unless name raise NotFound unless File.exists?(path) @renderer = Tilt.new(path) end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/pancake/mixins/render/template.rb', line 8 def name @name end |
#owner ⇒ Object (readonly)
Returns the value of attribute owner.
8 9 10 |
# File 'lib/pancake/mixins/render/template.rb', line 8 def owner @owner end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
8 9 10 |
# File 'lib/pancake/mixins/render/template.rb', line 8 def path @path end |
#renderer ⇒ Object (readonly)
Returns the value of attribute renderer.
8 9 10 |
# File 'lib/pancake/mixins/render/template.rb', line 8 def renderer @renderer end |
Instance Method Details
#render(context = ViewContext.new, opts = {}) ⇒ Object
17 18 19 |
# File 'lib/pancake/mixins/render/template.rb', line 17 def render(context = ViewContext.new, opts = {}) @renderer.render(context, opts) end |