Module: HamlLayouts::Models::Layout

Defined in:
lib/haml_layouts/models/layout.rb

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/haml_layouts/models/layout.rb', line 5

def self.included(base)
  base.class_eval do
    
    # Will render html from haml if necessary
    def rendered_content
      if is_haml?
        # The gsub will replace all escaped radius tags with html
        HamlFilter.filter(content)
      else
        content
      end
    end
    
    # Returns 'text/html' to the browser (if haml)           
    def content_type
      self[:content_type] == 'haml' ? 'text/html' : self[:content_type]
    end

    # Overwrites the standard Radiant Render and pumps out haml if necessary
    def is_haml?
      self[:content_type] == 'haml'
    end
    
  end
end