Sha256: 9c5e3626e2a2ce856d64135d9daa397cf68f3a5dab85f5142c938aad71ae4857

Contents?: true

Size: 1.08 KB

Versions: 27

Compression:

Stored size: 1.08 KB

Contents

# Require gem
require "coffee_script"

module Middleman
  module Renderers

    # CoffeeScript Renderer
    module CoffeeScript

      # Setup extension
      class << self
        # Once registered
        def registered(app)
          app.before_configuration do
            template_extensions :coffee => :js
          end

          # Tell Tilt to use it as well (for inline scss blocks)
          ::Tilt.register 'coffee', DebuggingCoffeeScriptTemplate
          ::Tilt.prefer(DebuggingCoffeeScriptTemplate)
        end
        alias :included :registered
      end

      # A Template for Tilt which outputs debug messages
      class DebuggingCoffeeScriptTemplate < ::Tilt::CoffeeScriptTemplate
        # Add exception messaging
        # @param [Class] context
        # @param [Hash] locals
        # @return [String]
        def evaluate(context, locals, &block)
          return super if context.build?

          begin
            super
          rescue ::ExecJS::RuntimeError => e
            e.to_s
          rescue => e
            e.to_s
          end
        end
      end
    end
  end
end

Version data entries

27 entries across 27 versions & 2 rubygems

Version Path
middleman-core-x86-mingw32-3.0.11 lib/middleman-core/renderers/coffee_script.rb
middleman-core-3.0.11 lib/middleman-core/renderers/coffee_script.rb
middleman-core-x86-mingw32-3.0.10 lib/middleman-core/renderers/coffee_script.rb
middleman-core-x86-mingw32-3.0.10.pre.1 lib/middleman-core/renderers/coffee_script.rb
middleman-core-3.0.10.pre.1 lib/middleman-core/renderers/coffee_script.rb
middleman-core-x86-mingw32-3.0.9 lib/middleman-core/renderers/coffee_script.rb
middleman-core-3.0.9 lib/middleman-core/renderers/coffee_script.rb
middleman-core-x86-mingw32-3.0.8 lib/middleman-core/renderers/coffee_script.rb
middleman-core-3.0.8 lib/middleman-core/renderers/coffee_script.rb
middleman-core-x86-mingw32-3.0.8.pre.2 lib/middleman-core/renderers/coffee_script.rb
middleman-core-3.0.8.pre.2 lib/middleman-core/renderers/coffee_script.rb
middleman-core-x86-mingw32-3.0.8.pre.1 lib/middleman-core/renderers/coffee_script.rb
middleman-core-3.0.8.pre.1 lib/middleman-core/renderers/coffee_script.rb
middleman-core-x86-mingw32-3.0.7 lib/middleman-core/renderers/coffee_script.rb
middleman-core-3.0.7 lib/middleman-core/renderers/coffee_script.rb
middleman-core-x86-mingw32-3.0.6 lib/middleman-core/renderers/coffee_script.rb
middleman-core-3.0.6 lib/middleman-core/renderers/coffee_script.rb
middleman-core-x86-mingw32-3.0.5 lib/middleman-core/renderers/coffee_script.rb
middleman-core-3.0.5 lib/middleman-core/renderers/coffee_script.rb
middleman-core-x86-mingw32-3.0.4 lib/middleman-core/renderers/coffee_script.rb