Skip to content

Commit a2fee02

Browse files
committed
Allow operation with handlebars runtime only
1 parent b993a76 commit a2fee02

File tree

1 file changed

+35
-21
lines changed
  • packages/ember-handlebars/lib

1 file changed

+35
-21
lines changed

packages/ember-handlebars/lib/ext.js

Lines changed: 35 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,12 @@ Ember.Handlebars.helpers = objectCreate(Handlebars.helpers);
4343
@constructor
4444
*/
4545
Ember.Handlebars.Compiler = function() {};
46-
Ember.Handlebars.Compiler.prototype = objectCreate(Handlebars.Compiler.prototype);
46+
47+
// Handlebars.Compiler doesn't exist in runtime-only
48+
if (Handlebars.Compiler) {
49+
Ember.Handlebars.Compiler.prototype = objectCreate(Handlebars.Compiler.prototype);
50+
}
51+
4752
Ember.Handlebars.Compiler.prototype.compiler = Ember.Handlebars.Compiler;
4853

4954
/**
@@ -53,8 +58,14 @@ Ember.Handlebars.Compiler.prototype.compiler = Ember.Handlebars.Compiler;
5358
@constructor
5459
*/
5560
Ember.Handlebars.JavaScriptCompiler = function() {};
56-
Ember.Handlebars.JavaScriptCompiler.prototype = objectCreate(Handlebars.JavaScriptCompiler.prototype);
57-
Ember.Handlebars.JavaScriptCompiler.prototype.compiler = Ember.Handlebars.JavaScriptCompiler;
61+
62+
// Handlebars.JavaScriptCompiler doesn't exist in runtime-only
63+
if (Handlebars.JavaScriptCompiler) {
64+
Ember.Handlebars.JavaScriptCompiler.prototype = objectCreate(Handlebars.JavaScriptCompiler.prototype);
65+
Ember.Handlebars.JavaScriptCompiler.prototype.compiler = Ember.Handlebars.JavaScriptCompiler;
66+
}
67+
68+
5869
Ember.Handlebars.JavaScriptCompiler.prototype.namespace = "Ember.Handlebars";
5970

6071

@@ -134,24 +145,27 @@ Ember.Handlebars.precompile = function(string) {
134145
return new Ember.Handlebars.JavaScriptCompiler().compile(environment, options, undefined, true);
135146
};
136147

137-
/**
138-
The entry point for Ember Handlebars. This replaces the default Handlebars.compile and turns on
139-
template-local data and String parameters.
140-
141-
@method compile
142-
@for Ember.Handlebars
143-
@static
144-
@param {String} string The template to compile
145-
@return {Function}
146-
*/
147-
Ember.Handlebars.compile = function(string) {
148-
var ast = Handlebars.parse(string);
149-
var options = { data: true, stringParams: true };
150-
var environment = new Ember.Handlebars.Compiler().compile(ast, options);
151-
var templateSpec = new Ember.Handlebars.JavaScriptCompiler().compile(environment, options, undefined, true);
152-
153-
return Handlebars.template(templateSpec);
154-
};
148+
// We don't support this for Handlebars runtime-only
149+
if (Handlebars.compile) {
150+
/**
151+
The entry point for Ember Handlebars. This replaces the default Handlebars.compile and turns on
152+
template-local data and String parameters.
153+
154+
@method compile
155+
@for Ember.Handlebars
156+
@static
157+
@param {String} string The template to compile
158+
@return {Function}
159+
*/
160+
Ember.Handlebars.compile = function(string) {
161+
var ast = Handlebars.parse(string);
162+
var options = { data: true, stringParams: true };
163+
var environment = new Ember.Handlebars.Compiler().compile(ast, options);
164+
var templateSpec = new Ember.Handlebars.JavaScriptCompiler().compile(environment, options, undefined, true);
165+
166+
return Handlebars.template(templateSpec);
167+
};
168+
}
155169

156170
/**
157171
@private

0 commit comments

Comments
 (0)