Class: LessAssets::LessTemplate
- Inherits:
-
Tilt::Template
- Object
- Tilt::Template
- LessAssets::LessTemplate
- Defined in:
- lib/less_assets/less_template.rb
Overview
Less template implementation for Tilt.
Class Attribute Summary collapse
-
.name_filter ⇒ Object
A proc that is called to modify the template name used as the JST key.
-
.namespace ⇒ Object
The JavaScript Style template namespace.
Class Method Summary collapse
-
.engine_initialized? ⇒ Boolean
Test if the compiler is initialized.
Instance Method Summary collapse
-
#evaluate(scope, locals = { }, &block) ⇒ String
Generates the Less template wrapped in a JavaScript template.
-
#initialize_engine ⇒ Object
Initialize the template engine.
-
#prepare ⇒ Object
Prepare the template.
Class Attribute Details
.name_filter ⇒ Object
A proc that is called to modify the template name used as the JST key. The proc is passed the name as an argument and should return the modified name (or unmodified) name.
15 16 17 |
# File 'lib/less_assets/less_template.rb', line 15 def name_filter @name_filter end |
.namespace ⇒ Object
The JavaScript Style template namespace
18 19 20 |
# File 'lib/less_assets/less_template.rb', line 18 def namespace @namespace end |
Class Method Details
.engine_initialized? ⇒ Boolean
Test if the compiler is initialized.
34 35 36 |
# File 'lib/less_assets/less_template.rb', line 34 def self.engine_initialized? true end |
Instance Method Details
#evaluate(scope, locals = { }, &block) ⇒ String
Generates the Less template wrapped in a JavaScript template
53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/less_assets/less_template.rb', line 53 def evaluate(scope, locals = { }, &block) name = scope.logical_path name = self.class.name_filter.call(name) if self.class.name_filter <<-JST (function() { #{ self.class.namespace } || (#{ self.class.namespace } = {}); #{ self.class.namespace }['#{ name }'] = function(v, e) { return LessAssets.render('#{ name }', \"#{ data.gsub(/\n/, "\\n") }\", v, e); }; }).call(this); JST end |
#initialize_engine ⇒ Object
Initialize the template engine.
40 41 |
# File 'lib/less_assets/less_template.rb', line 40 def initialize_engine end |
#prepare ⇒ Object
Prepare the template
45 46 |
# File 'lib/less_assets/less_template.rb', line 45 def prepare end |