Class: Stache::View
- Inherits:
-
Mustache
- Object
- Mustache
- Stache::View
- Defined in:
- lib/stache/view.rb
Overview
A Convienent Base Class for the views. Subclass this for autoloading magic with your templates.
e.g. if the handler is loading a template from templates/
Instance Attribute Summary collapse
-
#template ⇒ Object
Returns the value of attribute template.
-
#view ⇒ Object
Returns the value of attribute view.
Instance Method Summary collapse
- #method_missing(method, *args, &block) ⇒ Object
-
#partial(name) ⇒ Object
Redefine where Stache::View templates locate their partials:.
- #respond_to?(method, include_private = false) ⇒ Boolean
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
11 12 13 |
# File 'lib/stache/view.rb', line 11 def method_missing(method, *args, &block) view.send(method, *args, &block) end |
Instance Attribute Details
#template ⇒ Object
Returns the value of attribute template.
9 10 11 |
# File 'lib/stache/view.rb', line 9 def template @template end |
#view ⇒ Object
Returns the value of attribute view.
9 10 11 |
# File 'lib/stache/view.rb', line 9 def view @view end |
Instance Method Details
#partial(name) ⇒ Object
Redefine where Stache::View templates locate their partials:
(1) in the same directory as the current template file. (2) in the shared templates path (can be configured via Config.shared_path=(value))
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/stache/view.rb', line 24 def partial(name) partial_name = "_#{name}.#{Stache.template_extension}" template_dir = Pathname.new(self.class.template_file).dirname partial_path = File.(File.join(Stache.template_base_path, template_dir, partial_name)) unless File.file?(partial_path) partial_path = "#{Stache.shared_path}/#{partial_name}" end # ::Rails.logger.info "LOADING PARTIAL: #{partial_path}" File.read(partial_path) end |
#respond_to?(method, include_private = false) ⇒ Boolean
15 16 17 |
# File 'lib/stache/view.rb', line 15 def respond_to?(method, include_private=false) super(method, include_private) || view.respond_to?(method, include_private) end |