From 26e8ebe138b725778b2ef292fa93a7b14d75ba2c Mon Sep 17 00:00:00 2001 From: Brandon Payton Date: Sat, 29 Oct 2011 21:34:40 -0700 Subject: [PATCH] Replace tabs with 2 spaces. --- examples/dot_notation.js | 34 +++++++++++++------------- mustache.js | 52 ++++++++++++++++++++-------------------- 2 files changed, 43 insertions(+), 43 deletions(-) diff --git a/examples/dot_notation.js b/examples/dot_notation.js index f41fafb..c5c8fb2 100644 --- a/examples/dot_notation.js +++ b/examples/dot_notation.js @@ -1,18 +1,18 @@ var dot_notation = { - name: "A Book", - authors: ["John Power", "Jamie Walsh"], - price:{ - value: 200, - vat: function() { - return this.value * 0.2; - }, - currency: { - symbol: '€', - name: 'Euro' - } - }, - availability:{ - status: true, - text: "In Stock" - } -}; \ No newline at end of file + name: "A Book", + authors: ["John Power", "Jamie Walsh"], + price:{ + value: 200, + vat: function() { + return this.value * 0.2; + }, + currency: { + symbol: '€', + name: 'Euro' + } + }, + availability:{ + status: true, + text: "In Stock" + } +}; diff --git a/mustache.js b/mustache.js index 21d5726..e291f05 100644 --- a/mustache.js +++ b/mustache.js @@ -269,18 +269,18 @@ var Mustache = function() { } var value; - - // check for dot notation eg. foo.bar - if(name.match(/([a-z_]+)\./ig)){ - value = is_kinda_truthy(this.walk_context(name, context)); - } - else{ - if(is_kinda_truthy(context[name])) { - value = context[name]; - } else if(is_kinda_truthy(this.context[name])) { - value = this.context[name]; - } - } + + // check for dot notation eg. foo.bar + if(name.match(/([a-z_]+)\./ig)){ + value = is_kinda_truthy(this.walk_context(name, context)); + } + else{ + if(is_kinda_truthy(context[name])) { + value = context[name]; + } else if(is_kinda_truthy(this.context[name])) { + value = this.context[name]; + } + } if(typeof value === "function") { return value.apply(context); @@ -292,21 +292,21 @@ var Mustache = function() { return ""; }, - walk_context: function(name, context){ - var path = name.split('.'); - // if the var doesn't exist in current context, check the top level context - var value_context = (context[path[0]] != undefined) ? context : this.context; - var value = value_context[path.shift()]; - while(value != undefined && path.length > 0){ - value_context = value; - value = value[path.shift()]; - } - // if the value is a function, call it, binding the correct context - if(typeof value === "function") { + walk_context: function(name, context){ + var path = name.split('.'); + // if the var doesn't exist in current context, check the top level context + var value_context = (context[path[0]] != undefined) ? context : this.context; + var value = value_context[path.shift()]; + while(value != undefined && path.length > 0){ + value_context = value; + value = value[path.shift()]; + } + // if the value is a function, call it, binding the correct context + if(typeof value === "function") { return value.apply(value_context); } - return value; - }, + return value; + }, // Utility methods @@ -416,4 +416,4 @@ var Mustache = function() { } } }); -}(); \ No newline at end of file +}();