diff options
author | kpdecker <kpdecker@gmail.com> | 2014-08-13 20:46:07 -0500 |
---|---|---|
committer | kpdecker <kpdecker@gmail.com> | 2014-08-13 20:46:42 -0500 |
commit | c98613b711a70a82a960c20c00d8d92d5eed1024 (patch) | |
tree | 364862d90bc601284d35f5c19e8fed1abad7e4f4 /spec/blocks.js | |
parent | 625b00e1dafccc8653bf4cb4dc3dac55f6b3b020 (diff) | |
download | handlebars.js-c98613b711a70a82a960c20c00d8d92d5eed1024.zip handlebars.js-c98613b711a70a82a960c20c00d8d92d5eed1024.tar.gz handlebars.js-c98613b711a70a82a960c20c00d8d92d5eed1024.tar.bz2 |
Implement recursive field lookup in compat mode
Provides the mustache behavior of recursive lookup without the use of depthed paths.
Note that this does incur a fairly dramatic performance penalty for depthed queries.
Diffstat (limited to 'spec/blocks.js')
-rw-r--r-- | spec/blocks.js | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/spec/blocks.js b/spec/blocks.js index c57a67e..a13cce2 100644 --- a/spec/blocks.js +++ b/spec/blocks.js @@ -94,4 +94,25 @@ describe('blocks', function() { 'No people\n'); }); }); + + describe('compat mode', function() { + it("block with deep recursive lookup lookup", function() { + var string = "{{#outer}}Goodbye {{#inner}}cruel {{omg}}{{/inner}}{{/outer}}"; + var hash = {omg: "OMG!", outer: [{ inner: [{ text: "goodbye" }] }] }; + + shouldCompileTo(string, [hash, undefined, undefined, true], "Goodbye cruel OMG!"); + }); + it("block with deep recursive pathed lookup", function() { + var string = "{{#outer}}Goodbye {{#inner}}cruel {{omg.yes}}{{/inner}}{{/outer}}"; + var hash = {omg: {yes: "OMG!"}, outer: [{ inner: [{ yes: 'no', text: "goodbye" }] }] }; + + shouldCompileTo(string, [hash, undefined, undefined, true], "Goodbye cruel OMG!"); + }); + it("block with missed recursive lookup", function() { + var string = "{{#outer}}Goodbye {{#inner}}cruel {{omg.yes}}{{/inner}}{{/outer}}"; + var hash = {omg: {no: "OMG!"}, outer: [{ inner: [{ yes: 'no', text: "goodbye" }] }] }; + + shouldCompileTo(string, [hash, undefined, undefined, true], "Goodbye cruel "); + }); + }); }); |