Class: Embork::Sprockets::EmberHandlebarsCompiler
- Inherits:
-
Tilt::Template
- Object
- Tilt::Template
- Embork::Sprockets::EmberHandlebarsCompiler
- Defined in:
- lib/embork/sprockets/ember_handlebars_compiler.rb
Constant Summary collapse
- CJS_closure =
<<-CJS.strip_heredoc window.require.define({"%s": function(exports, require, module) { "use strict"; var template = %s exports["default"] = template; }}); CJS
- AMD_closure =
<<-AMD.strip_heredoc define("%s", ["exports"], function(__exports__) { "use strict"; var template = %s __exports__["default"] = template; }); AMD
Class Attribute Summary collapse
-
.compile_to ⇒ Object
Returns the value of attribute compile_to.
-
.namespace ⇒ Object
Returns the value of attribute namespace.
-
.transform ⇒ Object
Returns the value of attribute transform.
Class Method Summary collapse
Instance Method Summary collapse
Class Attribute Details
.compile_to ⇒ Object
Returns the value of attribute compile_to.
8 9 10 |
# File 'lib/embork/sprockets/ember_handlebars_compiler.rb', line 8 def compile_to @compile_to end |
.namespace ⇒ Object
Returns the value of attribute namespace.
10 11 12 |
# File 'lib/embork/sprockets/ember_handlebars_compiler.rb', line 10 def namespace @namespace end |
.transform ⇒ Object
Returns the value of attribute transform.
9 10 11 |
# File 'lib/embork/sprockets/ember_handlebars_compiler.rb', line 9 def transform @transform end |
Class Method Details
.closures(target) ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/embork/sprockets/ember_handlebars_compiler.rb', line 36 def closures(target) { :globals => "Ember.TEMPLATES['%s'] = %s", :cjs => CJS_closure, :amd => AMD_closure }[target] end |
Instance Method Details
#evaluate(scope, locals, &block) ⇒ Object
52 53 54 55 56 57 58 |
# File 'lib/embork/sprockets/ember_handlebars_compiler.rb', line 52 def evaluate(scope, locals, &block) @environment = scope.environment @logical_path = scope.logical_path template = Barber::Ember::FilePrecompiler.call(data) closure = self.class.closures(self.class.compile_to) closure % [ module_name, template ] end |
#module_name ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/embork/sprockets/ember_handlebars_compiler.rb', line 60 def module_name if self.class.transform name = self.class.transform.call @logical_path else name = @logical_path end # Attach the namespace if !self.class.namespace.nil? "%s/%s" % [ self.class.namespace.to_s, name ] else name end end |
#prepare ⇒ Object
48 49 50 |
# File 'lib/embork/sprockets/ember_handlebars_compiler.rb', line 48 def prepare # Required to be implemented by Tilt for some reason... end |