Class: Stache::Mustache::View
- Inherits:
-
Mustache
- Object
- Mustache
- Stache::Mustache::View
show all
- Defined in:
- lib/stache/mustache/view.rb
Overview
A Convienent Base Class for the views. Subclass this for autoloading magic with your templates.
Direct Known Subclasses
Layout
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
15
16
17
|
# File 'lib/stache/mustache/view.rb', line 15
def method_missing(method, *args, &block)
view.send(method, *args, &block)
end
|
Instance Attribute Details
#view ⇒ Object
Returns the value of attribute view.
8
9
10
|
# File 'lib/stache/mustache/view.rb', line 8
def view
@view
end
|
#virtual_path ⇒ Object
Returns the value of attribute virtual_path.
8
9
10
|
# File 'lib/stache/mustache/view.rb', line 8
def virtual_path
@virtual_path
end
|
Class Method Details
.helpers ⇒ Object
Also known as:
h
Instance Method Details
#context ⇒ Object
10
11
12
13
|
# File 'lib/stache/mustache/view.rb', line 10
def context
@context ||= FasterContext.new(self)
end
|
#h ⇒ Object
58
59
60
|
# File 'lib/stache/mustache/view.rb', line 58
def helpers
self.class.helpers
end
|
#helpers ⇒ Object
55
56
57
|
# File 'lib/stache/mustache/view.rb', line 55
def helpers
self.class.helpers
end
|
#partial(name) ⇒ Object
Redefine where Stache::View templates locate their partials
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/stache/mustache/view.rb', line 34
def partial(name)
cache_key = :"#{virtual_path}/#{name}"
template_cached = ::Stache.template_cache.read(cache_key, :namespace => :partials, :raw => true)
curr_template = template_cached || Stache::Mustache::CachedTemplate.new(
begin template_finder(name, true)
rescue ActionView::MissingTemplate
template_finder(name, false)
end.source
)
unless template_cached
::Stache.template_cache.write(cache_key, curr_template, :namespace => :partials, :raw => true)
end
curr_template
end
|
#respond_to?(method, include_private = false) ⇒ Boolean
19
20
21
|
# File 'lib/stache/mustache/view.rb', line 19
def respond_to?(method, include_private=false)
super(method, include_private) || view.respond_to?(method, include_private)
end
|