Sha256: 6e7ca0657a6925e70e9777abc452cb6417d83944eac2efe94b7d182a885d5922
Contents?: true
Size: 1.4 KB
Versions: 2
Compression:
Stored size: 1.4 KB
Contents
module Slim module Rails module RegisterEngine class Transformer def self.call(input) context = input[:environment].context_class.new(input) Slim::Template.new(input[:name]) { input[:data] }.render(context) end end class << self def register_engine(app, config) if ::Rails::VERSION::MAJOR == 3 _register_engine3(app) else _register_engine(config) end end private def _register_engine3(app) return unless app.assets return unless app.assets.respond_to?(:register_engine) app.assets.register_engine('.slim', Slim::Template) end def _register_engine(config) return unless config.respond_to?(:assets) config.assets.configure do |env| if env.respond_to?(:register_transformer) && Sprockets::VERSION.to_i > 3 env.register_mime_type 'text/slim', extensions: ['.slim', '.slim.html']#, charset: :html env.register_transformer 'text/slim', 'text/html', RegisterEngine::Transformer elsif env.respond_to?(:register_engine) args = ['.slim', Slim::Template] args << { silence_deprecation: true } if Sprockets::VERSION.start_with?('3') env.register_engine(*args) end end end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
slim-rails-3.4.0 | lib/slim-rails/register_engine.rb |
slim-rails-3.3.0 | lib/slim-rails/register_engine.rb |