Sha256: 15176febaa062ffecb8d8d8ed4818af272418fe057d99f2241a8e76bbd839f42

Contents?: true

Size: 1.18 KB

Versions: 10

Compression:

Stored size: 1.18 KB

Contents

module Padrino
  module Helpers
    module OutputHelpers
      # Haml and Hamlit require different detection code
      if defined?(Haml) && Tilt.template_for('.haml').to_s == "Padrino::Rendering::HamlTemplate"
        ##
        # Handler for Haml templates.
        #
        class HamlHandler < AbstractHandler
          ##
          # Returns true if the block is for Haml
          #
          def engine_matches?(block)
            template.block_is_haml?(block)
          end

          ##
          # Captures the html from a block of template code for this handler.
          #
          def capture_from_template(*args, &block)
            engine_matches?(block) ? template.capture_haml(*args, &block) : yield(*args)
          end
        end
        OutputHelpers.register(:haml, HamlHandler)
      else
        ##
        # Handler for Haml templates.
        #
        class HamlitHandler < AbstractHandler
          ##
          # Returns true if the block is for Hamlit.
          #
          def engine_matches?(block)
            block.binding.eval('defined? __in_hamlit_template')
          end
        end
        OutputHelpers.register(:haml, HamlitHandler)
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
padrino-helpers-0.16.0.pre3 lib/padrino-helpers/output_helpers/haml_handler.rb
padrino-helpers-0.16.0.pre2 lib/padrino-helpers/output_helpers/haml_handler.rb
padrino-helpers-0.15.3 lib/padrino-helpers/output_helpers/haml_handler.rb
padrino-helpers-0.15.2 lib/padrino-helpers/output_helpers/haml_handler.rb
padrino-helpers-0.15.1 lib/padrino-helpers/output_helpers/haml_handler.rb
padrino-helpers-0.15.0 lib/padrino-helpers/output_helpers/haml_handler.rb
padrino-helpers-0.14.4 lib/padrino-helpers/output_helpers/haml_handler.rb
padrino-helpers-0.14.3 lib/padrino-helpers/output_helpers/haml_handler.rb
padrino-helpers-0.14.2 lib/padrino-helpers/output_helpers/haml_handler.rb
padrino-helpers-0.14.1.1 lib/padrino-helpers/output_helpers/haml_handler.rb