Skip to content

Commit

Permalink
Merge pull request #131 from sethkinast/undefined-head
Browse files Browse the repository at this point in the history
Explicitly check context.stack.tail.head to make sure it is defined
  • Loading branch information
sethkinast committed Apr 13, 2015
2 parents beaf4f3 + 0ded5b3 commit 1f481f4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/dust-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ function _deprecated(target) {

function isSelect(context) {
return context.stack.tail &&
context.stack.tail.head &&
typeof context.stack.tail.head.__select__ !== "undefined";
}

Expand Down
7 changes: 7 additions & 0 deletions test/jasmine-test/spec/helpersTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,13 @@
context: {},
expected: "",
message: "eq helper without a body should fail gracefully and return nothing"
},
{
name: "eq helper with makeBase",
source: '{@eq key=hello value="world"}Hello{/eq}',
context: dust.makeBase({ hello:"world" }).push({ foo: "bar" }),
expected: "Hello",
message: "eq helper can draw from globals even when the stack is undefined"
}
]
},
Expand Down

0 comments on commit 1f481f4

Please sign in to comment.