Sha256: 609eb7628bcc8efbaada9e43af638310d43dab52e195e245cd7c25c291705a11

Contents?: true

Size: 852 Bytes

Versions: 21

Compression:

Stored size: 852 Bytes

Contents

module Padrino
  module Rendering
    class SlimOutputBuffer < 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 SlimTemplate < Slim::Template
      include SafeTemplate

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

Tilt.prefer(Padrino::Rendering::SlimTemplate, :slim)

Padrino::Rendering.engine_configurations[:slim] = {
  :generator => Padrino::Rendering::SlimOutputBuffer,
  :buffer => "@_out_buf",
  :use_html_safe => true,
  :disable_capture => true,
}

Version data entries

21 entries across 21 versions & 2 rubygems

Version Path
padrino-helpers-0.16.0.pre3 lib/padrino/rendering/slim_template.rb
padrino-helpers-0.16.0.pre2 lib/padrino/rendering/slim_template.rb
padrino-helpers-0.15.3 lib/padrino/rendering/slim_template.rb
padrino-helpers-0.15.2 lib/padrino/rendering/slim_template.rb
padrino-helpers-0.15.1 lib/padrino/rendering/slim_template.rb
files.com-1.0.55 docs/vendor/bundle/ruby/2.5.0/gems/padrino-helpers-0.13.3.4/lib/padrino/rendering/slim_template.rb
padrino-helpers-0.15.0 lib/padrino/rendering/slim_template.rb
padrino-helpers-0.14.4 lib/padrino/rendering/slim_template.rb
padrino-helpers-0.14.3 lib/padrino/rendering/slim_template.rb
padrino-helpers-0.14.2 lib/padrino/rendering/slim_template.rb
padrino-helpers-0.13.3.4 lib/padrino/rendering/slim_template.rb
padrino-helpers-0.14.1.1 lib/padrino/rendering/slim_template.rb
padrino-helpers-0.14.1 lib/padrino/rendering/slim_template.rb
padrino-helpers-0.14.0.2 lib/padrino/rendering/slim_template.rb
padrino-helpers-0.14.0.1 lib/padrino/rendering/slim_template.rb
padrino-helpers-0.14.0 lib/padrino/rendering/slim_template.rb
padrino-helpers-0.14.0.rc2 lib/padrino/rendering/slim_template.rb
padrino-helpers-0.14.0.rc1 lib/padrino/rendering/slim_template.rb
padrino-helpers-0.13.3.3 lib/padrino/rendering/slim_template.rb
padrino-helpers-0.13.3.2 lib/padrino/rendering/slim_template.rb