diff --git a/view/mustache/mustache.js b/view/mustache/mustache.js index af88529f5ac..671164112ce 100644 --- a/view/mustache/mustache.js +++ b/view/mustache/mustache.js @@ -528,7 +528,7 @@ function( can ){ i && result.push(','); // Check for special helper arguments (string/number/boolean/hashes). - if (i && (m = arg.match(/^(('.*?'|".*?"|[0-9.]+|true|false)|((.+?)=(('.*?'|".*?"|[0-9.]+|true|false)|(.+))))$/))) { + if (i && (m = arg.match(/^(('.*?'|".*?"|[0-9]+\.?[0-9]*|true|false)|((.+?)=(('.*?'|".*?"|[0-9]+\.?[0-9]*|true|false)|(.+))))$/))) { // Found a native type like string/number/boolean. if (m[2]) { result.push(m[0]); diff --git a/view/mustache/mustache_test.js b/view/mustache/mustache_test.js index d5128be0d4c..0e056bff6cb 100644 --- a/view/mustache/mustache_test.js +++ b/view/mustache/mustache_test.js @@ -1892,4 +1892,25 @@ test("Computes should be resolved prior to accessing attributes", function() { equal( div.innerHTML, "0" ); }) +test("Helpers can be passed . or this for the active context", function() { + can.Mustache.registerHelper('rsvp', function(attendee, event) { + return attendee.name + ' is attending ' + event.name; + }); + var template = can.view.mustache("{{#attendee}}{{#events}}
{{rsvp attendee .}}
{{/events}}{{/#attendee}}"), + data = { + attendee: { name: 'Justin' }, + events: [ + { name: 'Reception' }, + { name: 'Wedding' } + ] + }; + + var div = document.createElement('div'); + div.appendChild(template(data)); + var children = div.getElementsByTagName('div'); + + equal( children[0].innerHTML, 'Justin is attending Reception' ); + equal( children[1].innerHTML, 'Justin is attending Wedding' ); +}) + })();