| @@ -18,7 +18,7 @@ var Mustache = function() { | |||||
| render: function(template, context, partials, in_recursion) { | render: function(template, context, partials, in_recursion) { | ||||
| // fail fast | // fail fast | ||||
| if(template.indexOf(this.otag) == -1) { | |||||
| if(!this.includes("", template)) { | |||||
| if(in_recursion) { | if(in_recursion) { | ||||
| return template; | return template; | ||||
| } else { | } else { | ||||
| @@ -54,7 +54,7 @@ var Mustache = function() { | |||||
| */ | */ | ||||
| render_pragmas: function(template) { | render_pragmas: function(template) { | ||||
| // no pragmas | // no pragmas | ||||
| if(template.indexOf(this.otag + "%") == -1) { | |||||
| if(!this.includes("%", template)) { | |||||
| return template; | return template; | ||||
| } | } | ||||
| @@ -90,12 +90,13 @@ var Mustache = function() { | |||||
| }, | }, | ||||
| /* | /* | ||||
| Renders boolean and enumerable sections | |||||
| Renders inverted (^) and normal (#) sections | |||||
| */ | */ | ||||
| render_section: function(template, context, partials) { | render_section: function(template, context, partials) { | ||||
| if(template.indexOf(this.otag + "#") == -1) { | |||||
| if(!this.includes("#", template)) { | |||||
| return template; | return template; | ||||
| } | } | ||||
| var that = this; | var that = this; | ||||
| // CSW - Added "+?" so it finds the tighest bound, not the widest | // CSW - Added "+?" so it finds the tighest bound, not the widest | ||||
| var regex = new RegExp(this.otag + "\\#(.+)" + this.ctag + | var regex = new RegExp(this.otag + "\\#(.+)" + this.ctag + | ||||
| @@ -204,6 +205,11 @@ var Mustache = function() { | |||||
| // Utility methods | // Utility methods | ||||
| /* includes tag */ | |||||
| includes: function(needle, haystack) { | |||||
| return haystack.indexOf(this.otag + needle) != -1; | |||||
| }, | |||||
| /* | /* | ||||
| Does away with nasty characters | Does away with nasty characters | ||||
| */ | */ | ||||