Module: Raw::LayoutHelper

Defined in:
lib/raw/helper/layout.rb

Overview

This helper uses Nitro’s powerfull Elements mechanism to implement a simple Rails style Layout helper. Perhaps this may be useful for people coming over from Rails.

WARNING: This is not enabled by default. You have to insert the LayoutCompiler before the ElementsCompiler for layout to work.

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/raw/helper/layout.rb', line 17

def self.included(base)
  base.module_eval do    
    # Enclose all templates of this controller with the
    # given element.
    
    def self.layout(name = nil)
      klass = name.to_s.camelize
      
      unless klass
        if defined? 'Nitro::Element::Layout'
          klass = Nitro::Element::Layout
        end
      end
      
      if klass
        ann :self, :layout => klass
      end
    end
  end
end