Sha256: 17885ccfba0695a774f728d325d064fc206f353b7fc6b36767860c788fb63160

Contents?: true

Size: 919 Bytes

Versions: 5

Compression:

Stored size: 919 Bytes

Contents

module Munge
  module Transformers
    class TiltTransformer
      def initialize(system)
        @system = system
        @registry = []
        @demands = Hash.new { Hash.new }
      end

      def name
        :tilt
      end

      def call(item, content, renderer = nil)
        scope = Scope.new(@system.clone, @demands)
        @registry.each { |helpers| scope.extend(helpers) }

        scope.render_with_layout(item, content_engines: renderer, content_override: content)
      end

      def register(helper)
        @registry.push(helper)
      end

      def demand(tilt_template, **options)
        @demands[tilt_template] = @demands[tilt_template].merge(options)
      end

      class Scope
        def initialize(system, tilt_options)
          @system = system
          @tilt_options = tilt_options
        end

        attr_reader :system
        attr_reader :tilt_options
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
munge-0.18.0 lib/munge/transformers/tilt_transformer.rb
munge-0.17.0 lib/munge/transformers/tilt_transformer.rb
munge-0.16.0 lib/munge/transformers/tilt_transformer.rb
munge-0.15.1 lib/munge/transformers/tilt_transformer.rb
munge-0.15.0 lib/munge/transformers/tilt_transformer.rb