Sha256: 67444380ec1fd2911037c7f25dc3d1aa4d1675583cf24549f7d67e6239cc00b8

Contents?: true

Size: 1.16 KB

Versions: 2

Compression:

Stored size: 1.16 KB

Contents

require "haml"
require "sass/more"
require "monkey-lib"

begin
  require 'escape_utils/html/haml'
rescue LoadError
  if Monkey::Engine.mri? or Monkey::Engine.rbx?
    warn "Please run 'gem install escape_utils' to speed up Haml!"
  end
end

module Haml
  module More

    # skip autoload lines
    extend Monkey::Autoloader

    # Base class for all all Haml helper
    module AbstractHelper
      module ClassMethods
        def registered(klass)
          klass.helpers self
        end
      end

      def self.included(klass)
        klass.extend ClassMethods
        super
      end

      include Haml::Helpers

      # Will make use of capture_haml depending on whether it is called from
      # within Haml code or not. Thus helpers may be shared between Haml and
      # others (like ERB), but still enjoy all the fancy Haml::Helpers tools.
      def haml_helper(&block)
        return capture_haml(&block) unless is_haml?
        yield
      end

    end

    def self.included(klass)
      Haml::More::CoffeeScript.activate
      klass.send :include, Haml::More::ContentFor, Haml::More::Javascript
      super
    end

    ::Sinatra.helpers self if defined? ::Sinatra

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
haml-more-0.5.1 lib/haml/more.rb
haml-more-0.5.0 lib/haml/more.rb