@@ -579,6 +579,47 @@ describe('Unit: Stage 2 (AST)', () => {
579
579
} ) ;
580
580
} ) ;
581
581
} ) ;
582
+
583
+ describe ( 'Case: content_for' , ( ) => {
584
+ it ( 'should parse content_for tags with no arguments' , ( ) => {
585
+ for ( const { toAST, expectPath, expectPosition } of testCases ) {
586
+ ast = toAST ( `{% content_for "blocks" %}` ) ;
587
+ expectPath ( ast , 'children.0.type' ) . to . equal ( 'LiquidTag' ) ;
588
+ expectPath ( ast , 'children.0.name' ) . to . equal ( 'content_for' ) ;
589
+ expectPath ( ast , 'children.0.markup.type' ) . to . equal ( 'ContentForMarkup' ) ;
590
+ expectPath ( ast , 'children.0.markup.contentForType.type' ) . to . equal ( 'String' ) ;
591
+ expectPath ( ast , 'children.0.markup.contentForType.value' ) . to . equal ( 'blocks' ) ;
592
+ expectPosition ( ast , 'children.0' ) ;
593
+ expectPosition ( ast , 'children.0.markup' ) ;
594
+ }
595
+ } ) ;
596
+
597
+ it ( 'should parse content_for named expression arguments' , ( ) => {
598
+ for ( const { toAST, expectPath, expectPosition } of testCases ) {
599
+ ast = toAST ( `{% content_for "snippet", s: 'string', n: 10, r: (1..2), v: variable %}` ) ;
600
+ expectPath ( ast , 'children.0.type' ) . to . equal ( 'LiquidTag' ) ;
601
+ expectPath ( ast , 'children.0.name' ) . to . equal ( 'content_for' ) ;
602
+ expectPath ( ast , 'children.0.markup.type' ) . to . equal ( 'ContentForMarkup' ) ;
603
+ expectPath ( ast , 'children.0.markup.contentForType.type' ) . to . equal ( 'String' ) ;
604
+ expectPath ( ast , 'children.0.markup.contentForType.value' ) . to . equal ( 'snippet' ) ;
605
+ expectPath ( ast , 'children.0.markup.args' ) . to . have . lengthOf ( 4 ) ;
606
+ expectPath ( ast , 'children.0.markup.args.0.type' ) . to . equal ( 'NamedArgument' ) ;
607
+ expectPath ( ast , 'children.0.markup.args.0.name' ) . to . equal ( 's' ) ;
608
+ expectPath ( ast , 'children.0.markup.args.0.value.type' ) . to . equal ( 'String' ) ;
609
+ expectPath ( ast , 'children.0.markup.args.1.type' ) . to . equal ( 'NamedArgument' ) ;
610
+ expectPath ( ast , 'children.0.markup.args.1.name' ) . to . equal ( 'n' ) ;
611
+ expectPath ( ast , 'children.0.markup.args.1.value.type' ) . to . equal ( 'Number' ) ;
612
+ expectPath ( ast , 'children.0.markup.args.2.type' ) . to . equal ( 'NamedArgument' ) ;
613
+ expectPath ( ast , 'children.0.markup.args.2.name' ) . to . equal ( 'r' ) ;
614
+ expectPath ( ast , 'children.0.markup.args.2.value.type' ) . to . equal ( 'Range' ) ;
615
+ expectPath ( ast , 'children.0.markup.args.3.type' ) . to . equal ( 'NamedArgument' ) ;
616
+ expectPath ( ast , 'children.0.markup.args.3.name' ) . to . equal ( 'v' ) ;
617
+ expectPath ( ast , 'children.0.markup.args.3.value.type' ) . to . equal ( 'VariableLookup' ) ;
618
+ expectPosition ( ast , 'children.0' ) ;
619
+ expectPosition ( ast , 'children.0.markup' ) ;
620
+ }
621
+ } ) ;
622
+ } ) ;
582
623
} ) ;
583
624
584
625
it ( `should parse liquid inline comments` , ( ) => {
0 commit comments