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.
9
10
11
12
|
# File 'lib/alephant/preview/template/base.rb', line 9
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
18
19
20
21
|
# File 'lib/alephant/preview/template/base.rb', line 18
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.
7
8
9
|
# File 'lib/alephant/preview/template/base.rb', line 7
def regions
@regions
end
|
Instance Method Details
#region(components) ⇒ Object
27
28
29
30
31
32
33
|
# File 'lib/alephant/preview/template/base.rb', line 27
def region(components)
if components.is_a?(Array)
components.join
else
components
end
end
|
#respond_to?(method) ⇒ Boolean
23
24
25
|
# File 'lib/alephant/preview/template/base.rb', line 23
def respond_to?(method)
valid_regions.include? method.to_s
end
|
#static_host ⇒ Object
14
15
16
|
# File 'lib/alephant/preview/template/base.rb', line 14
def static_host
ENV["STATIC_HOST"] || "localhost:8000"
end
|
#valid_regions ⇒ Object
35
36
37
38
39
40
41
|
# File 'lib/alephant/preview/template/base.rb', line 35
def valid_regions
template.tokens.find_all do |token|
token.is_a?(Array) && token[0] == :mustache
end.map do |token|
token[2][2][0].to_s
end
end
|