Sha256: a67042e1b09a3b3736b80b5dc74b36355f8cd55db20fefd3014f7cbd3f2c3c35

Contents?: true

Size: 1.27 KB

Versions: 129

Compression:

Stored size: 1.27 KB

Contents

# Fake filters for Slim
module Slim
  class Embedded
    class TiltEngine
      def on_slim_embedded(engine, body, attrs)
        # Override this method to avoid Slim trying to load sass/scss and failing
        case engine
        when :sass, :scss, :coffee
          tilt_engine = nil # Doesn't really matter, ignored below
        else
          # Original Slim code
          tilt_engine = Tilt[engine] || raise(Temple::FilterError, "Tilt engine #{engine} is not available.")
        end

        tilt_options = options[engine.to_sym] || {}
        tilt_options[:default_encoding] ||= 'utf-8'

        [:multi, tilt_render(tilt_engine, tilt_options, collect_text(body)), collect_newlines(body)]
      end
    end

    class SassEngine
      protected

      def tilt_render(tilt_engine, tilt_options, text)
        [:dynamic,
         "BrakemanFilter.render(#{text.inspect}, #{self.class})"]
      end
    end

    class CoffeeEngine < TiltEngine
      protected

      def tilt_render(tilt_engine, tilt_options, text)
        [:dynamic,
         "BrakemanFilter.render(#{text.inspect}, #{self.class})"]
      end
    end

    # Override the engine for CoffeeScript, because Slim doesn't have
    # one, it just uses Tilt's
    register :coffee, JavaScriptEngine, engine: CoffeeEngine
  end
end

Version data entries

129 entries across 115 versions & 4 rubygems

Version Path
brakeman-4.10.1 lib/brakeman/parsers/slim_embedded.rb
brakeman-lib-4.10.1 lib/brakeman/parsers/slim_embedded.rb
brakeman-min-4.10.1 lib/brakeman/parsers/slim_embedded.rb
brakeman-min-5.0.0.pre1 lib/brakeman/parsers/slim_embedded.rb
brakeman-lib-5.0.0.pre1 lib/brakeman/parsers/slim_embedded.rb
brakeman-5.0.0.pre1 lib/brakeman/parsers/slim_embedded.rb
brakeman-4.10.0 lib/brakeman/parsers/slim_embedded.rb
brakeman-lib-4.10.0 lib/brakeman/parsers/slim_embedded.rb
brakeman-min-4.10.0 lib/brakeman/parsers/slim_embedded.rb
brakeman-4.9.1 lib/brakeman/parsers/slim_embedded.rb
brakeman-min-4.9.1 lib/brakeman/parsers/slim_embedded.rb
brakeman-lib-4.9.1 lib/brakeman/parsers/slim_embedded.rb
brakeman-4.9.0 lib/brakeman/parsers/slim_embedded.rb
brakeman-min-4.9.0 lib/brakeman/parsers/slim_embedded.rb
brakeman-lib-4.9.0 lib/brakeman/parsers/slim_embedded.rb
brakeman-4.8.2 lib/brakeman/parsers/slim_embedded.rb
brakeman-lib-4.8.2 lib/brakeman/parsers/slim_embedded.rb
brakeman-min-4.8.2 lib/brakeman/parsers/slim_embedded.rb
brakeman-4.8.1 lib/brakeman/parsers/slim_embedded.rb
brakeman-lib-4.8.1 lib/brakeman/parsers/slim_embedded.rb