Module: Opal::Haml

Defined in:
lib/opal/haml.rb,
lib/opal/haml/builder.rb,
lib/opal/haml/version.rb,
lib/opal/haml/processor.rb

Defined Under Namespace

Classes: HamlProcessor, Processor

Constant Summary collapse

VERSION =
'0.4.4'

Class Method Summary collapse

Class Method Details

.compile(source, file = '(haml)') ⇒ Object



15
16
17
# File 'lib/opal/haml.rb', line 15

def self.compile(source, file = '(haml)')
  Opal.compile(compile_haml(source, file))
end

.compile_haml(source, file) ⇒ Object



19
20
21
22
23
# File 'lib/opal/haml.rb', line 19

def self.compile_haml(source, file)
  haml = ::Haml::Engine.new(source, @options).precompiled
  haml = haml.gsub('_hamlout.buffer', '_hamlout')
  wrap(haml, file)
end

.wrap(haml, file) ⇒ Object



25
26
27
28
29
30
31
32
33
34
# File 'lib/opal/haml.rb', line 25

def self.wrap(haml, file)
  "    require 'opal-haml'\n    Template.new('\#{file}') do |_hamlout|\n      _hamlout.extend Haml::Buffer\n      \#{haml}\n      _hamlout.join\n    end\n  EOS\nend\n"