Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: opal/opal-haml
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 385e0d9d47eb
Choose a base ref
...
head repository: opal/opal-haml
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 1e4129149ea7
Choose a head ref
  • 3 commits
  • 2 files changed
  • 1 contributor

Commits on Mar 19, 2015

  1. Copy the full SHA
    fc86d64 View commit details
  2. Copy the full SHA
    81e2636 View commit details
  3. Rely on Opal::Processor to transform opal into js

    This way sourcemaps/compiler-options/whatever will be setup correctly.
    elia committed Mar 19, 2015
    Copy the full SHA
    1e41291 View commit details
Showing with 13 additions and 16 deletions.
  1. +6 −1 lib/opal/haml.rb
  2. +7 −15 lib/opal/haml/processor.rb
7 changes: 6 additions & 1 deletion lib/opal/haml.rb
Original file line number Diff line number Diff line change
@@ -6,13 +6,18 @@
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')
Opal.compile(wrap(haml, file))
wrap(haml, file)
end

def self.wrap(haml, file)
<<-EOS
require 'opal-haml'
Template.new('#{file}') do |_hamlout|
#{haml}
_hamlout.join
22 changes: 7 additions & 15 deletions lib/opal/haml/processor.rb
Original file line number Diff line number Diff line change
@@ -3,23 +3,15 @@

module Opal
module Haml
class Processor < Tilt::Template
self.default_mime_type = 'application/javascript'

def self.engine_initialized?
true
end

def initialize_engine
require_template_library 'opal'
end

def prepare
class Processor < ::Opal::Processor
def evaluate(context, locals, &block)
@data = Opal::Haml.compile_haml @data, context.logical_path.sub(/^templates\//, '')
super
end

def evaluate(context, locals, &block)
context.require_asset 'opal-haml'
Opal::Haml.compile data, context.logical_path.sub(/^templates\//, '')
def self.compiler_options
# otherwise would check current class `attr_accessor`s
::Opal::Processor.compiler_options
end
end
end