Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mustache specs - lambda compliance #304

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 6 additions & 2 deletions mustache.js
Expand Up @@ -258,9 +258,9 @@
} else if (typeof value === 'function') {
var text = template == null ? null : template.slice(token[3], token[5]);
value = value.call(context.view, text, function (template) {
return writer.render(template, context);
return writer.render('' + template, context);
});
if (value != null) buffer += value;
if (value != null) buffer += writer.render('' + value, context);
} else if (value) {
buffer += renderTokens(token[4], writer, context, template);
}
Expand All @@ -282,10 +282,14 @@
break;
case '&':
value = context.lookup(tokenValue);
if (typeof value === 'function')
value = writer.render('' + value.call(context.view), context);
if (value != null) buffer += value;
break;
case 'name':
value = context.lookup(tokenValue);
if (typeof value === 'function')
value = writer.render('' + value.call(context.view), context);
if (value != null) buffer += exports.escape(value);
break;
case 'text':
Expand Down
2 changes: 1 addition & 1 deletion test/_files/higher_order_sections.js
Expand Up @@ -3,7 +3,7 @@
helper: "To tinker?",
bolder: function () {
return function (text, render) {
return text + ' => <b>' + render(text) + '</b> ' + this.helper;
return '<b>' + render(text) + '</b> ' + this.helper;
}
}
})
2 changes: 1 addition & 1 deletion test/_files/higher_order_sections.txt
@@ -1 +1 @@
Hi {{name}}. => <b>Hi Tater.</b> To tinker?
<b>Hi Tater.</b> To tinker?
10 changes: 4 additions & 6 deletions test/mustache-spec-test.js
Expand Up @@ -4,6 +4,10 @@ var fs = require('fs');
var path = require('path');
var specsDir = path.join(__dirname, 'spec/specs');

// need to define globals used in ~lambdas - Interpolation - Multiple Calls
// otherwise mocha complains
g=null, calls=null;

var skipTests = {
comments: [
'Standalone Without Newline'
Expand All @@ -23,12 +27,6 @@ var skipTests = {
'Standalone Without Newline'
],
'~lambdas': [
'Interpolation',
'Interpolation - Expansion',
'Interpolation - Alternate Delimiters',
'Interpolation - Multiple Calls',
'Escaping',
'Section - Expansion',
'Section - Alternate Delimiters'
]
};
Expand Down