Sha256: 7ac05506abd215fe1c320aad3c64dd28bf09b21023e81ff94eeb72bbbe2c61fb

Contents?: true

Size: 1.17 KB

Versions: 14

Compression:

Stored size: 1.17 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

      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

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
plate-0.7.8 lib/plate/sass_template.rb
plate-0.7.7 lib/plate/sass_template.rb
plate-0.7.6 lib/plate/sass_template.rb
plate-0.7.5 lib/plate/sass_template.rb
plate-0.7.4 lib/plate/sass_template.rb
plate-0.7.3 lib/plate/sass_template.rb
plate-0.7.2 lib/plate/sass_template.rb
plate-0.7.1 lib/plate/sass_template.rb
plate-0.7.0 lib/plate/sass_template.rb
plate-0.7.0.pre5 lib/plate/sass_template.rb
plate-0.7.0.pre4 lib/plate/sass_template.rb
plate-0.7.0.pre3 lib/plate/sass_template.rb
plate-0.7.0.pre2 lib/plate/sass_template.rb
plate-0.7.0.pre lib/plate/sass_template.rb