class Malt::Engine::Coffee

Coffee Malt Engine

Public Instance Methods

render(params={}, &content) click to toggle source

Render coffee script to JavaScript.

Calls superclass method Malt::Engine::Abstract#render
# File lib/malt/engines/coffee.rb, line 12
def render(params={}, &content)
  into, text, file = parameters(params, :to, :text, :file)

  case into
  when :javascript, :js, nil
    ::CoffeeScript.compile(text, engine_options(params))
  else
    super(params, &content)
  end
end

Private Instance Methods

engine_options(params) click to toggle source
# File lib/malt/engines/coffee.rb, line 37
def engine_options(params)
  options = {}
  options[:bare] = params[:bare] || params[:no_wrap] || false
  options
end
require_engine() click to toggle source

Load CoffeeScript library if not already loaded.

# File lib/malt/engines/coffee.rb, line 31
def require_engine
  return if defined? ::CoffeeScript
  require_library 'coffee_script'
end