Class: MDWA::Layout::Base
- Inherits:
-
Object
- Object
- MDWA::Layout::Base
- Defined in:
- lib/mdwa/layout/base.rb
Class Attribute Summary collapse
-
.routes_table ⇒ Object
Returns the value of attribute routes_table.
Class Method Summary collapse
-
.config {|@routes_table| ... } ⇒ Object
Define layout mappings.
-
.select_layout(route) ⇒ Object
returns the corresponding layout of the current route.
Class Attribute Details
.routes_table ⇒ Object
Returns the value of attribute routes_table.
11 12 13 |
# File 'lib/mdwa/layout/base.rb', line 11 def routes_table @routes_table end |
Class Method Details
.config {|@routes_table| ... } ⇒ Object
Define layout mappings. For example:
map ‘/*’, ‘layout_padraozao’ map ‘/administrator/*’, ‘layout_administrator’ map ‘/a/administrator/*’, ‘layout_a_administrador’ map ‘controller#*’, ‘layout_controller’ map ‘/administrator/controller#*’, ‘layout_administrator_controller’
map ‘/administrator/controller#action’, ‘layout1’ map ‘controller#action’, ‘layout2’
24 25 26 27 |
# File 'lib/mdwa/layout/base.rb', line 24 def config @routes_table = {} yield @routes_table if block_given? end |
.select_layout(route) ⇒ Object
returns the corresponding layout of the current route
30 31 32 33 34 35 36 |
# File 'lib/mdwa/layout/base.rb', line 30 def select_layout(route) # if route is namespaced, corrects the request if !route.rindex('/').nil? and route[0] != '/' route = "/#{route}" end return layout(route) end |