Class: Sprockets::WalrusTemplate
- Inherits:
-
Tilt::Template
- Object
- Tilt::Template
- Sprockets::WalrusTemplate
- Defined in:
- lib/sprockets/walrus_template.rb
Defined Under Namespace
Modules: JSHelper
Class Attribute Summary collapse
-
.namespace ⇒ Object
Returns the value of attribute namespace.
Instance Attribute Summary collapse
-
#namespace ⇒ Object
readonly
Returns the value of attribute namespace.
Class Method Summary collapse
Instance Method Summary collapse
Class Attribute Details
.namespace ⇒ Object
Returns the value of attribute namespace.
11 12 13 |
# File 'lib/sprockets/walrus_template.rb', line 11 def namespace @namespace end |
Instance Attribute Details
#namespace ⇒ Object (readonly)
Returns the value of attribute namespace.
20 21 22 |
# File 'lib/sprockets/walrus_template.rb', line 20 def namespace @namespace end |
Class Method Details
.default_mime_type ⇒ Object
6 7 8 |
# File 'lib/sprockets/walrus_template.rb', line 6 def self.default_mime_type 'application/javascript' end |
Instance Method Details
#evaluate(scope, locals, &block) ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/sprockets/walrus_template.rb', line 22 def evaluate(scope, locals, &block) <<-JST (function() { #{namespace} || (#{namespace} = {}); var parsed = Walrus.Parser.parse('#{escaped_javascript(data)}'); #{namespace}[#{scope.logical_path.inspect}] = function(obj) { return parsed.compile(obj) }; }).call(this); JST end |
#prepare ⇒ Object
16 17 18 |
# File 'lib/sprockets/walrus_template.rb', line 16 def prepare @namespace = self.class.namespace end |