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 partials = data.to_s.scan(/@import\s"(.*?)";/i).flatten.collect { |s| s.split('/').last } scope.partials = scope.partials + partials ::Sass::Engine.new(data, options).render end end end