Sha256: d1f84a25946553ba5a85d7762c5223fd348149ac9643db4932d535bcac8de67f

Contents?: true

Size: 836 Bytes

Versions: 11

Compression:

Stored size: 836 Bytes

Contents

module Padrino
  module Rendering
    class HamlitOutputBuffer < Temple::Generators::StringBuffer
      define_options :buffer_class => 'SafeBuffer'

      def call(exp)
        [preamble, compile(exp), postamble].flatten.compact.join('; '.freeze)
      end

      def create_buffer
        "#{buffer} = #{options[:buffer_class]}.new"
      end

      def concat(str)
        "#{buffer}.safe_concat((#{str}))"
      end
    end

    class HamlitTemplate < Hamlit::Template
      include SafeTemplate

      def precompiled_preamble(locals)
        "__in_hamlit_template = true\n" << super
      end
    end
  end
end

Tilt.prefer(Padrino::Rendering::HamlitTemplate, :haml)

Padrino::Rendering.engine_configurations[:haml] = {
  :generator => Padrino::Rendering::HamlitOutputBuffer,
  :buffer => "@_out_buf",
  :use_html_safe => true,
}

Version data entries

11 entries across 11 versions & 1 rubygems

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