Class: Plate::SassTemplate

Inherits:
Tilt::Template
  • Object
show all
Defined in:
lib/plate/sass_template.rb

Overview

Extended from the base Tilt::Template class at: github.com/rtomayko/tilt/blob/master/lib/tilt/css.rb

Modifications have been made to use the site caching folder.

Direct Known Subclasses

ScssTemplate

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.engine_initialized?Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/plate/sass_template.rb', line 9

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

Instance Method Details

#evaluate(scope, locals, &block) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/plate/sass_template.rb', line 24

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

#initialize_engineObject



13
14
15
# File 'lib/plate/sass_template.rb', line 13

def initialize_engine
  require_template_library 'sass'
end

#prepareObject



17
18
# File 'lib/plate/sass_template.rb', line 17

def prepare
end

#syntaxObject



20
21
22
# File 'lib/plate/sass_template.rb', line 20

def syntax
  :sass
end