Sha256: bc30dc3c95e9cd652317d4e388c66c820ebc4f9e602bb75702507c53697af2da

Contents?: true

Size: 1.51 KB

Versions: 26

Compression:

Stored size: 1.51 KB

Contents

require 'sass'
require 'sass/rails/cache_store'
require 'sass/rails/helpers'
require 'sprockets/sass_functions'
require 'tilt'

module Sass
  module Rails
    class SassTemplate < Tilt::Template
      def self.default_mime_type
        'text/css'
      end

      def self.engine_initialized?
        true
      end

      def initialize_engine
      end

      def prepare
      end

      def syntax
        :sass
      end

      def evaluate(context, locals, &block)
        cache_store = CacheStore.new(context.environment)

        options = {
          :filename => eval_file,
          :line => line,
          :syntax => syntax,
          :cache_store => cache_store,
          :importer => importer_class.new(context.pathname.to_s),
          :load_paths => context.environment.paths.map { |path| importer_class.new(path.to_s) },
          :sprockets => {
            :context => context,
            :environment => context.environment
          }
        }

        sass_config = context.sass_config.merge(options)

        engine = ::Sass::Engine.new(data, sass_config)
        css = engine.render

        engine.dependencies.map do |dependency|
          context.depend_on(dependency.options[:filename])
        end

        css
      rescue ::Sass::SyntaxError => e
        context.__LINE__ = e.sass_backtrace.first[:line]
        raise e
      end

      private

      def importer_class
        SassImporter
      end
    end

    class ScssTemplate < SassTemplate
      def syntax
        :scss
      end
    end
  end
end

Version data entries

26 entries across 26 versions & 5 rubygems

Version Path
zuora_connect_ui-0.10.0 vendor/ruby/2.6.0/gems/sass-rails-5.0.7/lib/sass/rails/template.rb
zuora_connect_ui-0.9.2 vendor/ruby/2.6.0/gems/sass-rails-5.0.7/lib/sass/rails/template.rb
chatops-rpc-0.0.2 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/sass-rails-5.1.0/lib/sass/rails/template.rb
chatops-rpc-0.0.1 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/sass-rails-5.1.0/lib/sass/rails/template.rb
zuora_connect_ui-0.9.1 vendor/ruby/2.6.0/gems/sass-rails-5.0.7/lib/sass/rails/template.rb
zuora_connect_ui-0.9.0 vendor/ruby/2.6.0/gems/sass-rails-5.0.7/lib/sass/rails/template.rb
zuora_connect_ui-0.8.3 vendor/ruby/2.6.0/gems/sass-rails-5.0.7/lib/sass/rails/template.rb
zuora_connect_ui-0.8.2 vendor/ruby/2.6.0/gems/sass-rails-5.0.7/lib/sass/rails/template.rb
sass-rails-5.0.8 lib/sass/rails/template.rb
sass-rails-5.1.0 lib/sass/rails/template.rb
zuora_connect_ui-0.8.1 vendor/ruby/2.6.0/gems/sass-rails-5.0.7/lib/sass/rails/template.rb
zuora_connect_ui-0.8.0 vendor/ruby/2.6.0/gems/sass-rails-5.0.7/lib/sass/rails/template.rb
zuora_connect_ui-0.7.1 vendor/ruby/2.6.0/gems/sass-rails-5.0.7/lib/sass/rails/template.rb
zuora_connect_ui-0.7.0 vendor/ruby/2.6.0/gems/sass-rails-5.0.7/lib/sass/rails/template.rb
sass-rails-5.0.7 lib/sass/rails/template.rb
sass-rails-5.0.6 lib/sass/rails/template.rb
sass-rails-5.0.5 lib/sass/rails/template.rb
sc_core-0.0.7 test/dummy/vendor/bundle/ruby/2.2.0/gems/sass-rails-5.0.4/lib/sass/rails/template.rb
sass-rails-5.0.4 lib/sass/rails/template.rb
solidus_backend-1.0.0.pre3 vendor/bundle/gems/sass-rails-5.0.3/lib/sass/rails/template.rb