Sha256: f2c21de8e1f6e5c897b921818840718dd2be1c70f2fc57e71718e4124419a27d

Contents?: true

Size: 1.71 KB

Versions: 34

Compression:

Stored size: 1.71 KB

Contents

module Padrino
  module Helpers
    module OutputHelpers
      ##
      # Handler for reading and writing from a haml template.
      #
      class HamlHandler < AbstractHandler
        ##
        # Returns true if the current template type is same as this handlers; false otherwise.
        #
        # @example
        #   @handler.is_type? => true
        #
        def is_type?
          template.respond_to?(:is_haml?) && template.is_haml?
        end

        ##
        # Returns true if the block given is of the handler's template type; false otherwise.
        #
        # @example
        #   @handler.block_is_type?(block) => true
        #
        def block_is_type?(block)
          template.block_is_haml?(block)
        end

        # Captures the html from a block of template code for this handler
        #
        # @example
        #   @handler.capture_from_template(&block) => "...html..."
        #
        def capture_from_template(*args, &block)
          eval("_hamlout ||= @haml_buffer", block.binding) # this is for rbx
          template.capture_haml(*args, &block)
        end

        ##
        # Outputs the given text to the templates buffer directly
        #
        # @example
        #   @handler.concat_to_template("This will be output to the template buffer")
        #
        def concat_to_template(text="")
          template.haml_concat(text)
          nil
        end

        ##
        # Returns an array of engines used for the template
        #
        # @example
        #   @handler.engines => [:haml]
        #
        def engines
          @_engines ||= [:haml]
        end
      end # HamlHandler

      OutputHelpers.register(HamlHandler)
    end # OutputHelpers
  end # Helpers
end # Padrino

Version data entries

34 entries across 34 versions & 3 rubygems

Version Path
middleman-core-3.2.0 lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/output_helpers/haml_handler.rb
middleman-core-3.1.6 lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/output_helpers/haml_handler.rb
middleman-core-3.1.5 lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/output_helpers/haml_handler.rb
padrino-helpers-0.11.3 lib/padrino-helpers/output_helpers/haml_handler.rb
middleman-core-3.1.4 lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/output_helpers/haml_handler.rb
middleman-core-3.1.3 lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/output_helpers/haml_handler.rb
middleman-core-3.1.2 lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/output_helpers/haml_handler.rb
middleman-core-3.1.1 lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/output_helpers/haml_handler.rb
middleman-core-3.1.0 lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/output_helpers/haml_handler.rb
middleman-core-3.1.0.rc.4 lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/output_helpers/haml_handler.rb
middleman-core-3.1.0.rc.3 lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/output_helpers/haml_handler.rb
middleman-core-3.1.0.rc.2 lib/vendored-middleman-deps/padrino-helpers-0.10.7/lib/padrino-helpers/output_helpers/haml_handler.rb
padrino-helpers-0.11.2 lib/padrino-helpers/output_helpers/haml_handler.rb
padrino-helpers-0.11.1 lib/padrino-helpers/output_helpers/haml_handler.rb
padrino-helpers-0.11.0 lib/padrino-helpers/output_helpers/haml_handler.rb
padrino-helpers-0.10.7 lib/padrino-helpers/output_helpers/haml_handler.rb
middleman-core-3.0.0.beta.2 lib/middleman-core/vendor/padrino-helpers-0.10.6/lib/padrino-helpers/output_helpers/haml_handler.rb
padrino-helpers-0.10.6 lib/padrino-helpers/output_helpers/haml_handler.rb
padrino-helpers-0.10.6.e lib/padrino-helpers/output_helpers/haml_handler.rb
padrino-helpers-0.10.6.d lib/padrino-helpers/output_helpers/haml_handler.rb