Class: Haml::Generator

Inherits:
Object
  • Object
show all
Includes:
Temple::Mixins::CompiledDispatcher, Temple::Mixins::Options
Defined in:
lib/haml/generator.rb

Overview

Ruby code generator, which is a limited version of Temple::Generator. Limit methods since Haml doesn’t need most of them.

Instance Method Summary collapse

Instance Method Details

#call(exp)

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

def call(exp)
  compile(exp)
end

#on_code(exp)

28
29
30
# File 'lib/haml/generator.rb', line 28

def on_code(exp)
  exp
end

#on_dynamic(code)

24
25
26
# File 'lib/haml/generator.rb', line 24

def on_dynamic(code)
  concat(code)
end

#on_multi(*exp)

16
17
18
# File 'lib/haml/generator.rb', line 16

def on_multi(*exp)
  exp.map { |e| compile(e) }.join('; ')
end

#on_newline

32
33
34
# File 'lib/haml/generator.rb', line 32

def on_newline
  "\n"
end

#on_static(text)

20
21
22
# File 'lib/haml/generator.rb', line 20

def on_static(text)
  concat(options[:freeze_static] ? "#{Util.inspect_obj(text)}.freeze" : Util.inspect_obj(text))
end