summaryrefslogtreecommitdiffstats
path: root/lib/handlebars/runtime.js
diff options
context:
space:
mode:
authorkpdecker <kpdecker@gmail.com>2014-08-13 20:46:07 -0500
committerkpdecker <kpdecker@gmail.com>2014-08-13 20:46:42 -0500
commitc98613b711a70a82a960c20c00d8d92d5eed1024 (patch)
tree364862d90bc601284d35f5c19e8fed1abad7e4f4 /lib/handlebars/runtime.js
parent625b00e1dafccc8653bf4cb4dc3dac55f6b3b020 (diff)
downloadhandlebars.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 'lib/handlebars/runtime.js')
-rw-r--r--lib/handlebars/runtime.js8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/handlebars/runtime.js b/lib/handlebars/runtime.js
index 530dbd2..ec54f53 100644
--- a/lib/handlebars/runtime.js
+++ b/lib/handlebars/runtime.js
@@ -63,6 +63,14 @@ export function template(templateSpec, env) {
// Just add water
var container = {
+ lookup: function(depths, name) {
+ var len = depths.length;
+ for (var i = 0; i < len; i++) {
+ if (depths[i] && depths[i][name] != null) {
+ return depths[i][name];
+ }
+ }
+ },
lambda: function(current, context) {
return typeof current === 'function' ? current.call(context) : current;
},