Skip to content

Commit

Permalink
Add named block support
Browse files Browse the repository at this point in the history
  • Loading branch information
John Ratcliff committed Dec 18, 2017
1 parent 320411d commit f2d96a0
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/pegjs/html/tag-string.pegjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ start = tagString

tagString
= c:$tagChar+
tagChar = [_a-zA-Z0-9-] / nonSeparatorColon
tagChar = [_a-zA-Z0-9-] / nonSeparatorColon / '@'
14 changes: 14 additions & 0 deletions tests/integration/glimmer-component-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,17 @@ test('recursive nesting part 2', function(){
' p Hello');
compilesTo(emblem, '<my-comp-1><my-comp-2><p>Hello</p></my-comp-2></my-comp-1>');
});

test('named block support', function() {
var emblem = w(
'% x-modal',
' % @header as |@title|',
' |Header #{title}',
' % @body',
' |Body',
' % @footer',
' |Footer'
)

compilesTo(emblem, '<x-modal><@header as |@title|>Header {{title}}</@header><@body>Body</@body><@footer>Footer</@footer></x-modal>');
});
24 changes: 24 additions & 0 deletions tests/integration/mustaches-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -529,3 +529,27 @@ test('mustache with else if and complex statements', function() {
compilesTo(emblem,
'{{#if foo}}<p>Hi!</p>{{else if (eq 1 (and-or a=b showHidden=(eq 1 2)))}}<p>Wow what was that?</p>{{/if}}');
});

test('named block support', function() {
var emblem = w(
'= x-modal',
' % @header as |@title|',
' |Header #{title}',
' % @body',
' |Body',
' % @footer',
' |Footer'
)

compilesTo(emblem, '{{#x-modal}}<@header as |@title|>Header {{title}}</@header><@body>Body</@body><@footer>Footer</@footer>{{/x-modal}}');
});

test('named block with block param', function() {
var emblem = w(
'= x-layout as |@widget|',
' = @widget as |a b c|',
' |Hi.'
)

compilesTo(emblem, '{{#x-layout as |@widget|}}{{#@widget as |a b c|}}Hi.{{/@widget}}{{/x-layout}}');
});

0 comments on commit f2d96a0

Please sign in to comment.