Sha256: 8bf4d9bc4edf22229757232420b2b34a622ac4017bf699afa45b4392a21ee9a6

Contents?: true

Size: 811 Bytes

Versions: 1

Compression:

Stored size: 811 Bytes

Contents

# frozen_string_literal: true
module Jade
  # Sprockets 2, 3 & 4 interface
  # https://github.com/rails/sprockets/blob/master/guides/extending_sprockets.md#registering-all-versions-of-sprockets-in-processors
  class SprocketsTransformer
    def initialize(filename, &block)
      @filename = filename
      @source   = block.call
    end

    def render(context, empty_hash_wtf)
      self.class.run(@filename, @source, context)
    end

    def self.run(filename, source, context)
      Jade.compile(source, filename: filename, client: true)
    end

    def self.call(input)
      filename = input[:filename]
      source   = input[:data]
      context  = input[:environment].context_class.new(input)

      result = run(filename, source, context)
      context.metadata.merge(data: result)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pug-rails-2.0.2 lib/jade-rails/template.rb