Drop omitted content tags from generated output
This commit is contained in:
@@ -222,7 +222,9 @@ Compiler.prototype = {
|
||||
},
|
||||
|
||||
content: function(content) {
|
||||
this.opcode('appendContent', content.string);
|
||||
if (!content.omit) {
|
||||
this.opcode('appendContent', content.string);
|
||||
}
|
||||
},
|
||||
|
||||
mustache: function(mustache) {
|
||||
|
||||
@@ -83,4 +83,15 @@ describe('blocks', function() {
|
||||
"No people");
|
||||
});
|
||||
});
|
||||
|
||||
describe('standalone sections', function() {
|
||||
it('block standalone else sections', function() {
|
||||
shouldCompileTo('{{#people}}\n{{name}}\n{{^}}\n{{none}}\n{{/people}}\n', {none: 'No people'},
|
||||
'No people\n');
|
||||
shouldCompileTo('{{#none}}\n{{.}}\n{{^}}\n{{none}}\n{{/none}}\n', {none: 'No people'},
|
||||
'No people\n');
|
||||
shouldCompileTo('\n{{#people}}\n{{name}}\n{{^}}\n{{none}}\n{{/people}}\n', {none: 'No people'},
|
||||
'No people\n');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
+20
-2
@@ -24,7 +24,19 @@ describe('Regressions', function() {
|
||||
});
|
||||
|
||||
it("bug reported by @fat where lambdas weren't being properly resolved", function() {
|
||||
var string = "<strong>This is a slightly more complicated {{thing}}.</strong>.\n{{! Just ignore this business. }}\nCheck this out:\n{{#hasThings}}\n<ul>\n{{#things}}\n<li class={{className}}>{{word}}</li>\n{{/things}}</ul>.\n{{/hasThings}}\n{{^hasThings}}\n\n<small>Nothing to check out...</small>\n{{/hasThings}}";
|
||||
var string = '<strong>This is a slightly more complicated {{thing}}.</strong>.\n'
|
||||
+ '{{! Just ignore this business. }}\n'
|
||||
+ 'Check this out:\n'
|
||||
+ '{{#hasThings}}\n'
|
||||
+ '<ul>\n'
|
||||
+ '{{#things}}\n'
|
||||
+ '<li class={{className}}>{{word}}</li>\n'
|
||||
+ '{{/things}}</ul>.\n'
|
||||
+ '{{/hasThings}}\n'
|
||||
+ '{{^hasThings}}\n'
|
||||
+ '\n'
|
||||
+ '<small>Nothing to check out...</small>\n'
|
||||
+ '{{/hasThings}}';
|
||||
var data = {
|
||||
thing: function() {
|
||||
return "blah";
|
||||
@@ -39,7 +51,13 @@ describe('Regressions', function() {
|
||||
}
|
||||
};
|
||||
|
||||
var output = "<strong>This is a slightly more complicated blah.</strong>.\n\nCheck this out:\n\n<ul>\n\n<li class=one>@fat</li>\n\n<li class=two>@dhg</li>\n\n<li class=three>@sayrer</li>\n</ul>.\n\n";
|
||||
var output = '<strong>This is a slightly more complicated blah.</strong>.\n'
|
||||
+ 'Check this out:\n'
|
||||
+ '<ul>\n'
|
||||
+ '<li class=one>@fat</li>\n'
|
||||
+ '<li class=two>@dhg</li>\n'
|
||||
+ '<li class=three>@sayrer</li>\n'
|
||||
+ '</ul>.\n';
|
||||
shouldCompileTo(string, data, output);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user