Class: Alephant::Preview::Template::Base
- Inherits:
-
Mustache
- Object
- Mustache
- Alephant::Preview::Template::Base
show all
- Defined in:
- lib/alephant/preview/template/base.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(regions, template_location) ⇒ Base
Returns a new instance of Base.
10
11
12
13
|
# File 'lib/alephant/preview/template/base.rb', line 10
def initialize(regions, template_location)
@regions=regions
self.template_file = template_location
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
19
20
21
22
|
# File 'lib/alephant/preview/template/base.rb', line 19
def method_missing(name, *args, &block)
return super unless respond_to? name.to_s
region @regions[name.to_s]
end
|
Instance Attribute Details
#regions ⇒ Object
Returns the value of attribute regions.
8
9
10
|
# File 'lib/alephant/preview/template/base.rb', line 8
def regions
@regions
end
|
Instance Method Details
#region(components) ⇒ Object
28
29
30
31
32
33
34
|
# File 'lib/alephant/preview/template/base.rb', line 28
def region(components)
if components.kind_of?(Array)
components.join
else
components
end
end
|
#respond_to?(method) ⇒ Boolean
24
25
26
|
# File 'lib/alephant/preview/template/base.rb', line 24
def respond_to?(method)
valid_regions.include? method.to_s
end
|
#static_host ⇒ Object
15
16
17
|
# File 'lib/alephant/preview/template/base.rb', line 15
def static_host
ENV['STATIC_HOST'] || 'localhost:8000'
end
|
#valid_regions ⇒ Object
36
37
38
39
40
41
42
|
# File 'lib/alephant/preview/template/base.rb', line 36
def valid_regions
self.template.tokens.find_all { |token|
token.is_a?(Array) && token[0] == :mustache
}.map{ |token|
token[2][2][0].to_s
}
end
|