Skip to content
Browse files

added . notation to the {{a.b}} expressions

  • Loading branch information...
1 parent d24cd1b commit 4582f7cd1b835d36ae29c3ad98f4ed74313669cd @mhevery committed Jan 4, 2010
Showing with 13 additions and 6 deletions.
  1. +13 −6 lib/plugins/sammy.mustache.js
View
19 lib/plugins/sammy.mustache.js
@@ -159,14 +159,21 @@ var Mustache = function() {
*/
find: function(name, context) {
name = this.trim(name);
- if(typeof context[name] === "function") {
- return context[name].apply(context);
+ var value = context;
+ var path = name.split('.');
+ for (var i=0; i < path.length; i++) {
+ if (value) {
+ value = value[path[i]];
+ }
}
- if(context[name] !== undefined) {
- return context[name];
+ if(typeof value === "function") {
+ return value.apply(context);
+ } else if(value !== undefined) {
+ return value;
+ } else {
+ // silently ignore unknown variables
+ return "";
}
- // silently ignore unkown variables
- return "";
},
// Utility methods

0 comments on commit 4582f7c

Please sign in to comment.
Something went wrong with that request. Please try again.