fix: prevent zero length tokens in raw-blocks (#1577)
This comment ensures that the lexer is not stuck on zero-length tokens, in raw-blocks like {{{{a}}}} {{{{/a}}}}
This commit is contained in:
+28
-7
@@ -28,14 +28,35 @@ describe('helpers', function() {
|
||||
'raw block helper gets raw content');
|
||||
});
|
||||
|
||||
it('helper for nested raw block gets raw content', function() {
|
||||
var string = '{{{{a}}}} {{{{b}}}} {{{{/b}}}} {{{{/a}}}}';
|
||||
var helpers = {
|
||||
a: function(options) {
|
||||
describe('raw block parsing (with identity helper-function)', function() {
|
||||
|
||||
function runWithIdentityHelper(template, expected) {
|
||||
var helpers = {
|
||||
identity: function(options) {
|
||||
return options.fn();
|
||||
}
|
||||
};
|
||||
shouldCompileTo(string, [{}, helpers], ' {{{{b}}}} {{{{/b}}}} ', 'raw block helper should get nested raw block as raw content');
|
||||
}
|
||||
};
|
||||
shouldCompileTo(template, [{}, helpers], expected);
|
||||
}
|
||||
|
||||
it('helper for nested raw block gets raw content', function() {
|
||||
runWithIdentityHelper('{{{{identity}}}} {{{{b}}}} {{{{/b}}}} {{{{/identity}}}}', ' {{{{b}}}} {{{{/b}}}} ');
|
||||
});
|
||||
|
||||
it('helper for nested raw block works with empty content', function() {
|
||||
runWithIdentityHelper('{{{{identity}}}}{{{{/identity}}}}', '');
|
||||
});
|
||||
|
||||
it('helper for nested raw block works if nested raw blocks are broken', function() {
|
||||
runWithIdentityHelper('{{{{identity}}}} {{{{a}}}} {{{{ {{{{/ }}}} }}}} {{{{/identity}}}}', ' {{{{a}}}} {{{{ {{{{/ }}}} }}}} ');
|
||||
});
|
||||
|
||||
it('helper for nested raw block throw exception when with missing closing braces', function() {
|
||||
var string = '{{{{a}}}} {{{{/a';
|
||||
shouldThrow(function() {
|
||||
Handlebars.compile(string)();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('helper block with identical context', function() {
|
||||
|
||||
Reference in New Issue
Block a user