Allow distinguishing tag names in badpenny.
This commit is contained in:
@@ -7,7 +7,7 @@ badpenny = rr.Parser({
|
||||
rr.Literal('}}')),
|
||||
rr.Sequence(
|
||||
rr.Literal('{{('),
|
||||
rr.SavedLiteral('tagname'),
|
||||
rr.Node('name', rr.SingleLineText()),
|
||||
rr.Literal('}}'),
|
||||
rr.MultiLineText(),
|
||||
rr.Literal('{{)'),
|
||||
@@ -22,7 +22,7 @@ badpenny = rr.Parser({
|
||||
rr.Literal('}}')),
|
||||
rr.Sequence(
|
||||
rr.Literal('{{['),
|
||||
rr.SavedLiteral('tagname'),
|
||||
rr.Node('name', rr.SingleLineText()),
|
||||
rr.Literal('}}'),
|
||||
rr.MultiLineText(),
|
||||
rr.Literal('{{]'),
|
||||
@@ -31,7 +31,7 @@ badpenny = rr.Parser({
|
||||
|
||||
'value': rr.Node('value', rr.Sequence(
|
||||
rr.Literal('{{'),
|
||||
rr.SingleLineText(),
|
||||
rr.Node('name', rr.SingleLineText()),
|
||||
rr.Literal('}}'))),
|
||||
|
||||
'chunk': rr.Or(
|
||||
@@ -44,4 +44,7 @@ badpenny = rr.Parser({
|
||||
rr.ZeroOrMore(rr.Ref('chunk')),
|
||||
rr.EndOfText()))
|
||||
}, [
|
||||
rr.ChildToAttribute('container', 'name'),
|
||||
rr.ChildToAttribute('repeated', 'name'),
|
||||
rr.ChildToAttribute('value', 'name')
|
||||
]);
|
||||
|
||||
@@ -114,14 +114,16 @@ QUnit.test('Base', function(assert) {
|
||||
assert.expect(1);
|
||||
var content = [
|
||||
'foo{{value1}}bar',
|
||||
'foo{{(container}}contents{{)nottheend}}more contents{{)container}}bar',
|
||||
'foo{{[repeated}}testing{{]notthis}}{{)repeated}}zig{{]repeated}}bar'
|
||||
'foo{{(container1}}contents{{)nottheend}}more contents{{)container1}}bar',
|
||||
'foo{{[repeated1}}testing{{]notthis}}{{)repeated1}}zig{{]repeated1}}bar'
|
||||
].join('\n');
|
||||
|
||||
var expected = [
|
||||
'foo<value>value1</value>bar\n',
|
||||
'foo<container>contents{{)nottheend}}more contents</container>bar\n',
|
||||
'foo<repeated>testing{{]notthis}}{{)repeated}}zig</repeated>bar'
|
||||
'foo<value name="value1"></value>bar\n',
|
||||
'foo<container name="container1">contents{{)nottheend}}more contents',
|
||||
'</container>bar\n',
|
||||
'foo<repeated name="repeated1">testing{{]notthis}}{{)repeated1}}zig',
|
||||
'</repeated>bar'
|
||||
].join('');
|
||||
|
||||
assert.equal(badpenny.parseFromString(content).innerHTML, expected);
|
||||
|
||||
Reference in New Issue
Block a user