Sha256: 686b9cac7943c096289f094c337cff5668bcc31d7a14b4f41fc277b8ce70a323

Contents?: true

Size: 882 Bytes

Versions: 1

Compression:

Stored size: 882 Bytes

Contents

require "tilt"

module Sprockets
  module Sass
    class SassTemplate < Tilt::SassTemplate
      self.default_mime_type = "text/css"
      
      # A reference to the current Sprockets context
      attr_reader :context
      
      # Define the expected syntax for the template
      def syntax
        :sass
      end
      
      def prepare
        @context = nil
        @output  = nil
      end
      
      def evaluate(context, locals, &block)
        @output ||= begin
          @context = context
          ::Sass::Engine.new(data, sass_options).render
        end
      end

      private
      
      def sass_options
        options.merge(
          :filename => eval_file,
          :line     => line,
          :syntax   => syntax,
          :importer => importer
        )
      end
      
      def importer
        Importer.new context
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sprockets-sass-0.2.3 lib/sprockets/sass/sass_template.rb