Sha256: a22033dedf293fa55d7c567f76e89c53b26f708b44bb7430d50b102e5ff135cb

Contents?: true

Size: 692 Bytes

Versions: 3

Compression:

Stored size: 692 Bytes

Contents

require 'opal'
require 'opal/haml/builder'
require 'opal/haml/processor'
require 'opal/haml/version'

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

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

    def self.wrap(haml, file)
      <<-EOS
        require 'opal-haml'
        Template.new('#{file}') do |_hamlout|
          #{haml}
          _hamlout.join
        end
      EOS
    end
  end
end

Opal.append_path File.expand_path('../../../opal', __FILE__).untaint

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
opal-haml-0.4.2 lib/opal/haml.rb
opal-haml-0.4.1 lib/opal/haml.rb
opal-haml-0.4.0 lib/opal/haml.rb