@@ -27,6 +27,9 @@ export function template(templateSpec, env) {
|
||||
if (!env) {
|
||||
throw new Exception("No environment passed to template");
|
||||
}
|
||||
if (!templateSpec || !templateSpec.main) {
|
||||
throw new Exception('Unknown template object: ' + typeof templateSpec);
|
||||
}
|
||||
|
||||
// Note: Using env.VM references rather than local var references throughout this section to allow
|
||||
// for external users to override these as psuedo-supported APIs.
|
||||
@@ -151,6 +154,7 @@ export function template(templateSpec, env) {
|
||||
throw new Exception('_child can not be used with depthed methods');
|
||||
}
|
||||
|
||||
// TODO : Fix this
|
||||
return container.programWithDepth(i);
|
||||
};
|
||||
return ret;
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
/*globals Handlebars, shouldThrow */
|
||||
|
||||
describe('runtime', function() {
|
||||
describe('#template', function() {
|
||||
it('should throw on invalid templates', function() {
|
||||
shouldThrow(function() {
|
||||
Handlebars.template({});
|
||||
}, Error, 'Unknown template object: object');
|
||||
shouldThrow(function() {
|
||||
Handlebars.template();
|
||||
}, Error, 'Unknown template object: undefined');
|
||||
shouldThrow(function() {
|
||||
Handlebars.template('');
|
||||
}, Error, 'Unknown template object: string');
|
||||
});
|
||||
it('should throw on version mismatch', function() {
|
||||
shouldThrow(function() {
|
||||
Handlebars.template({
|
||||
main: true,
|
||||
compiler: [Handlebars.COMPILER_REVISION + 1]
|
||||
});
|
||||
}, Error, /Template was precompiled with a newer version of Handlebars than the current runtime/);
|
||||
shouldThrow(function() {
|
||||
Handlebars.template({
|
||||
main: true,
|
||||
compiler: [Handlebars.COMPILER_REVISION - 1]
|
||||
});
|
||||
}, Error, /Template was precompiled with an older version of Handlebars than the current runtime/);
|
||||
shouldThrow(function() {
|
||||
Handlebars.template({
|
||||
main: true
|
||||
});
|
||||
}, Error, /Template was precompiled with an older version of Handlebars than the current runtime/);
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user