Class: Juggalo::Layout
- Inherits:
-
Mustache
- Object
- Mustache
- Juggalo::Layout
show all
- Defined in:
- lib/juggalo/layout.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(template_location) ⇒ Layout
Returns a new instance of Layout.
7
8
9
10
|
# File 'lib/juggalo/layout.rb', line 7
def initialize(template_location)
@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
12
13
14
15
|
# File 'lib/juggalo/layout.rb', line 12
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.
5
6
7
|
# File 'lib/juggalo/layout.rb', line 5
def regions
@regions
end
|
Instance Method Details
#region(components) ⇒ Object
21
22
23
|
# File 'lib/juggalo/layout.rb', line 21
def region(components)
components.map { |c| c.present }.join unless components.nil?
end
|
#respond_to?(method) ⇒ Boolean
17
18
19
|
# File 'lib/juggalo/layout.rb', line 17
def respond_to?(method)
valid_regions.include? method.to_s
end
|
#valid_regions ⇒ Object
25
26
27
28
29
30
31
|
# File 'lib/juggalo/layout.rb', line 25
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
|