Permalink
Browse files

smarter parsing of tags with helpers, smarter iteration of helpers

  • Loading branch information...
1 parent 55cce25 commit 815cd14218ad0826c686ca30ccf47dbfa835f975 @janl committed Nov 13, 2011
Showing with 5 additions and 7 deletions.
  1. +5 −7 mustache.js
View
@@ -273,11 +273,8 @@ var Mustache = function() {
var helpers;
// check for helper e.g. name = "name|helperfun"
- var helper_name = name.split("|");
- if(helper_name.length > 1) { // we have at least one helper
- name = helper_name[0];
- helpers = helper_name.slice(1);
- }
+ var helpers = name.split("|");
+ name = helpers.shift();
// check for dot notation eg. foo.bar
if(name.match(/([a-z_]+)\./ig)){
@@ -298,8 +295,9 @@ var Mustache = function() {
value = value.apply(context);
}
- if(helpers) {
- for(var idx in helpers) {
+ var number_of_helpers = helpers.length;
+ if(number_of_helpers > 0) {
+ for(var idx = 0; idx < number_of_helpers; idx++) {
var helper = helpers[idx];
if(!this.helper_functions[helper]
|| typeof this.helper_functions[helper] != "function") {

0 comments on commit 815cd14

Please sign in to comment.