Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/handlebars/runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export function template(templateSpec, env) {
// Just add water
let container = {
strict: function (obj, name, loc) {
if (!obj || !(name in obj)) {
if (!obj || (typeof obj === 'object' && !(name in obj))) {
throw new Exception('"' + name + '" not defined in ' + obj, {
loc: loc,
});
Expand Down
12 changes: 8 additions & 4 deletions spec/strict.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ describe('strict', function () {
});

xt.toThrow(Error);

xt.withRuntimeOptions({ data: { hello: 'foo' } }).toCompileTo('foo');
});

Expand Down Expand Up @@ -87,9 +86,7 @@ describe('strict', function () {

it('should allow undefined hash when passed to helpers', function () {
expectTemplate('{{helper value=@foo}}')
.withCompileOptions({
strict: true,
})
.withCompileOptions({ strict: true })
.withHelpers({
helper: function (options) {
equals('value' in options.hash, true);
Expand All @@ -100,6 +97,13 @@ describe('strict', function () {
.toCompileTo('success');
});

it('should allow compat-mode combined with strict-mode', function () {
expectTemplate('Foo {{bar}}')
.withCompileOptions({ compat: true, strict: true })
.withInput({ bar: 'baz' })
.toCompileTo('Foo baz');
});

it('should show error location on missing property lookup', function () {
expectTemplate('\n\n\n {{hello}}')
.withCompileOptions({ strict: true })
Expand Down