Class: Rail::Processor::Haml

Inherits:
Base
  • Object
show all
Defined in:
lib/rail/processor/haml.rb

Instance Attribute Summary

Attributes inherited from Base

#pipeline

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

capable?, extensify, #initialize

Constructor Details

This class inherits a constructor from Rail::Processor::Base

Class Method Details

.input_extensionObject



4
5
6
# File 'lib/rail/processor/haml.rb', line 4

def self.input_extension
  'haml'
end

.mime_typeObject



12
13
14
# File 'lib/rail/processor/haml.rb', line 12

def self.mime_type
  'text/html'
end

.output_extensionObject



8
9
10
# File 'lib/rail/processor/haml.rb', line 8

def self.output_extension
  'html'
end

Instance Method Details

#compile(filename, options = {}, &block) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/rail/processor/haml.rb', line 16

def compile(filename, options = {}, &block)
  options = {
    filename: filename,
    line: 1,
    ugly: compress?
  }.merge(options)

  engine = ::Haml::Engine.new(File.read(filename), options)

  layout_filename = find_layout(filename)

  if layout_filename
    compile(layout_filename, options) do
      engine.render(options[:context], {}, &block)
    end
  else
    engine.render(options[:context], {}, &block)
  end
end