Sha256: c5cca9c3f5c26e55809afb8097014df6a45fe99b1adfebfd70774bd86b4293d5

Contents?: true

Size: 1.13 KB

Versions: 1

Compression:

Stored size: 1.13 KB

Contents

module Plate
  # Extended from the base Tilt::Template class at:
  # https://github.com/rtomayko/tilt/blob/master/lib/tilt/css.rb
  #
  # Modifications have been made to use the site caching folder.
  class SassTemplate < Tilt::Template
    self.default_mime_type = 'text/css'

    def self.engine_initialized?
      defined? ::Sass::Engine
    end

    def initialize_engine
      require_template_library 'sass'
    end

    def prepare
    end

    def syntax
      :sass
    end

    def evaluate(scope, locals, &block)
      paths = [ scope.pathname, File.join(scope.site.source, 'content') ]
      style = scope.site.options[:sass_style] || 'expanded'

      options = {
        :filename => eval_file,
        :line => line,
        :syntax => syntax,
        :style => style.to_sym,
        :load_paths => paths,
        :site => scope.site
      }

      if scope.site.cache_location
        options[:cache_location] = File.join(scope.site.cache_location, 'sass-cache')
      end

      scope.partials = data.to_s.scan(/@import\s"(.*?)";/i).flatten.collect { |s| s.split('/').last }

      ::Sass::Engine.new(data, options).render
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
plate-0.6.3 lib/plate/sass_template.rb