Class: Sprockets::Sass::SassTemplate

Inherits:
Tilt::SassTemplate
  • Object
show all
Defined in:
lib/sprockets/sass/sass_template.rb

Direct Known Subclasses

ScssTemplate

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#contextObject (readonly)

A reference to the current Sprockets context



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

def context
  @context
end

Class Method Details

.engine_initialized?Boolean

Templates are initialized once the



12
13
14
# File 'lib/sprockets/sass/sass_template.rb', line 12

def self.engine_initialized?
  super && defined?(@@sass_functions_added)
end

Instance Method Details

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

See `Tilt::Template#evaluate`.



46
47
48
49
50
51
# File 'lib/sprockets/sass/sass_template.rb', line 46

def evaluate(context, locals, &block)
  @output ||= begin
    @context = context
    ::Sass::Engine.new(data, sass_options).render
  end
end

#initialize_engineObject

Add the Sass functions if they haven't already been added.



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/sprockets/sass/sass_template.rb', line 17

def initialize_engine
  super
  
  if Sass.add_sass_functions
    begin
      require "sprockets/sass/functions"
    rescue LoadError
      # Safely ignore load issues, because
      # sprockets-helpers may not be available.
      @@sass_functions_added = false
    end
    @@sass_functions_added = true
  else
    @@sass_functions_added = false
  end
end

#prepareObject

See `Tilt::Template#prepare`.



40
41
42
43
# File 'lib/sprockets/sass/sass_template.rb', line 40

def prepare
  @context = nil
  @output  = nil
end

#syntaxObject

Define the expected syntax for the template



35
36
37
# File 'lib/sprockets/sass/sass_template.rb', line 35

def syntax
  :sass
end