Class: Flatrack::Sass::SassTemplate
- Inherits:
-
Tilt::SassTemplate
- Object
- Tilt::SassTemplate
- Flatrack::Sass::SassTemplate
- Defined in:
- lib/flatrack/sass/sass_template.rb
Direct Known Subclasses
Class Attribute Summary collapse
-
.sass_functions_initialized ⇒ Object
(also: sass_functions_initialized?)
Returns the value of attribute sass_functions_initialized.
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
A reference to the current Sprockets context.
Class Method Summary collapse
-
.engine_initialized? ⇒ Boolean
Templates are initialized once the functions are added.
Instance Method Summary collapse
-
#evaluate(context, locals, &block) ⇒ Object
See ‘Tilt::Template#evaluate`.
-
#initialize_engine ⇒ Object
Add the Sass functions if they haven’t already been added.
-
#prepare ⇒ Object
See ‘Tilt::Template#prepare`.
-
#syntax ⇒ Object
Define the expected syntax for the template.
Class Attribute Details
.sass_functions_initialized ⇒ Object Also known as: sass_functions_initialized?
Returns the value of attribute sass_functions_initialized.
15 16 17 |
# File 'lib/flatrack/sass/sass_template.rb', line 15 def sass_functions_initialized @sass_functions_initialized end |
Instance Attribute Details
#context ⇒ Object (readonly)
A reference to the current Sprockets context
9 10 11 |
# File 'lib/flatrack/sass/sass_template.rb', line 9 def context @context end |
Class Method Details
.engine_initialized? ⇒ Boolean
Templates are initialized once the functions are added.
19 20 21 |
# File 'lib/flatrack/sass/sass_template.rb', line 19 def engine_initialized? super && sass_functions_initialized? end |
Instance Method Details
#evaluate(context, locals, &block) ⇒ Object
See ‘Tilt::Template#evaluate`.
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/flatrack/sass/sass_template.rb', line 42 def evaluate(context, locals, &block) @output ||= begin @context = context ::Sass::Engine.new(data, ).render rescue ::Sass::SyntaxError => e # Annotates exception message with parse line number context.__LINE__ = e.sass_backtrace.first[:line] raise e end end |
#initialize_engine ⇒ Object
Add the Sass functions if they haven’t already been added.
25 26 27 28 |
# File 'lib/flatrack/sass/sass_template.rb', line 25 def initialize_engine super unless self.class.superclass.engine_initialized? require 'flatrack/sass/functions' end |
#prepare ⇒ Object
See ‘Tilt::Template#prepare`.
36 37 38 39 |
# File 'lib/flatrack/sass/sass_template.rb', line 36 def prepare @context = nil @output = nil end |
#syntax ⇒ Object
Define the expected syntax for the template
31 32 33 |
# File 'lib/flatrack/sass/sass_template.rb', line 31 def syntax :sass end |