Commit 80f9974 1 parent 11a52a7 commit 80f9974 Copy full SHA for 80f9974
File tree 6 files changed +25123
-19769
lines changed
6 files changed +25123
-19769
lines changed Original file line number Diff line number Diff line change @@ -306,11 +306,18 @@ module.exports = grammar(html, {
306
306
) ,
307
307
"}" ,
308
308
repeat ( $ . _node ) ,
309
+ field ( 'alternative' , optional ( $ . smarty_foreachelse_nodes ) ) ,
309
310
"{/" ,
310
311
keyword ( "foreach" ) ,
311
312
"}"
312
313
) ,
313
314
315
+ smarty_foreachelse_nodes : ( $ ) => seq (
316
+ prefixedKeyword ( "{" , "foreachelse" ) ,
317
+ "}" ,
318
+ field ( 'body' , repeat ( $ . _node ) ) ,
319
+ ) ,
320
+
314
321
smarty_function_definition : $ => seq (
315
322
prefixedKeyword ( "{" , "function" ) ,
316
323
field ( "function_name" , $ . smarty_name ) ,
Original file line number Diff line number Diff line change 78
78
(smarty_if_attrval_dq alternative: (smarty_else_attrval_dq (" }" @punctuation.special)))
79
79
80
80
(smarty_foreach_nodes [" {/" " }" ] @punctuation.special)
81
+ (smarty_foreach_nodes alternative: (smarty_foreachelse_nodes (" }" @punctuation.special)))
81
82
(smarty_foreach_nodes " as" @keyword)
82
83
(smarty_foreach_nodes " =>" @punctuation.delimiter)
83
84
87
88
" elseif" @keyword
88
89
" else" @keyword
89
90
" foreach" @keyword
91
+ " foreachelse" @keyword
90
92
" function" @keyword
91
93
92
94
; #eq? is builtin to treesitter (or at least mentioned by the docs),
120
122
(#lua-match? @punctuation.special.foreach_start " ^%s*{foreach" )
121
123
(#offset! @punctuation.special.foreach_start 0 0 0 -7)
122
124
)
125
+ (
126
+ (" foreachelse" @punctuation.special.foreachelse_start)
127
+ (#lua-match? @punctuation.special.foreachelse_start " ^%s*{foreachelse" )
128
+ (#offset! @punctuation.special.foreachelse_start 0 0 0 -11)
129
+ )
Original file line number Diff line number Diff line change 2717
2717
"name" : " _node"
2718
2718
}
2719
2719
},
2720
+ {
2721
+ "type" : " FIELD" ,
2722
+ "name" : " alternative" ,
2723
+ "content" : {
2724
+ "type" : " CHOICE" ,
2725
+ "members" : [
2726
+ {
2727
+ "type" : " SYMBOL" ,
2728
+ "name" : " smarty_foreachelse_nodes"
2729
+ },
2730
+ {
2731
+ "type" : " BLANK"
2732
+ }
2733
+ ]
2734
+ }
2735
+ },
2720
2736
{
2721
2737
"type" : " STRING" ,
2722
2738
"value" : " {/"
2736
2752
}
2737
2753
]
2738
2754
},
2755
+ "smarty_foreachelse_nodes" : {
2756
+ "type" : " SEQ" ,
2757
+ "members" : [
2758
+ {
2759
+ "type" : " ALIAS" ,
2760
+ "content" : {
2761
+ "type" : " TOKEN" ,
2762
+ "content" : {
2763
+ "type" : " SEQ" ,
2764
+ "members" : [
2765
+ {
2766
+ "type" : " STRING" ,
2767
+ "value" : " {"
2768
+ },
2769
+ {
2770
+ "type" : " IMMEDIATE_TOKEN" ,
2771
+ "content" : {
2772
+ "type" : " ALIAS" ,
2773
+ "content" : {
2774
+ "type" : " PATTERN" ,
2775
+ "value" : " [fF][oO][rR][eE][aA][cC][hH][eE][lL][sS][eE]"
2776
+ },
2777
+ "named" : false ,
2778
+ "value" : " foreachelse"
2779
+ }
2780
+ }
2781
+ ]
2782
+ }
2783
+ },
2784
+ "named" : false ,
2785
+ "value" : " foreachelse"
2786
+ },
2787
+ {
2788
+ "type" : " STRING" ,
2789
+ "value" : " }"
2790
+ },
2791
+ {
2792
+ "type" : " FIELD" ,
2793
+ "name" : " body" ,
2794
+ "content" : {
2795
+ "type" : " REPEAT" ,
2796
+ "content" : {
2797
+ "type" : " SYMBOL" ,
2798
+ "name" : " _node"
2799
+ }
2800
+ }
2801
+ }
2802
+ ]
2803
+ },
2739
2804
"smarty_function_definition" : {
2740
2805
"type" : " SEQ" ,
2741
2806
"members" : [
Original file line number Diff line number Diff line change 1497
1497
"type" : " smarty_foreach_nodes" ,
1498
1498
"named" : true ,
1499
1499
"fields" : {
1500
+ "alternative" : {
1501
+ "multiple" : false ,
1502
+ "required" : false ,
1503
+ "types" : [
1504
+ {
1505
+ "type" : " smarty_foreachelse_nodes" ,
1506
+ "named" : true
1507
+ }
1508
+ ]
1509
+ },
1500
1510
"from" : {
1501
1511
"multiple" : true ,
1502
1512
"required" : false ,
1655
1665
]
1656
1666
}
1657
1667
},
1668
+ {
1669
+ "type" : " smarty_foreachelse_nodes" ,
1670
+ "named" : true ,
1671
+ "fields" : {
1672
+ "body" : {
1673
+ "multiple" : true ,
1674
+ "required" : false ,
1675
+ "types" : [
1676
+ {
1677
+ "type" : " doctype" ,
1678
+ "named" : true
1679
+ },
1680
+ {
1681
+ "type" : " element" ,
1682
+ "named" : true
1683
+ },
1684
+ {
1685
+ "type" : " erroneous_end_tag" ,
1686
+ "named" : true
1687
+ },
1688
+ {
1689
+ "type" : " script_element" ,
1690
+ "named" : true
1691
+ },
1692
+ {
1693
+ "type" : " smarty_assignment" ,
1694
+ "named" : true
1695
+ },
1696
+ {
1697
+ "type" : " smarty_comment" ,
1698
+ "named" : true
1699
+ },
1700
+ {
1701
+ "type" : " smarty_foreach_nodes" ,
1702
+ "named" : true
1703
+ },
1704
+ {
1705
+ "type" : " smarty_function_call" ,
1706
+ "named" : true
1707
+ },
1708
+ {
1709
+ "type" : " smarty_function_definition" ,
1710
+ "named" : true
1711
+ },
1712
+ {
1713
+ "type" : " smarty_if_nodes" ,
1714
+ "named" : true
1715
+ },
1716
+ {
1717
+ "type" : " smarty_interpolation" ,
1718
+ "named" : true
1719
+ },
1720
+ {
1721
+ "type" : " style_element" ,
1722
+ "named" : true
1723
+ },
1724
+ {
1725
+ "type" : " text" ,
1726
+ "named" : true
1727
+ }
1728
+ ]
1729
+ }
1730
+ }
1731
+ },
1658
1732
{
1659
1733
"type" : " smarty_function_call" ,
1660
1734
"named" : true ,
3099
3173
"type" : " foreach" ,
3100
3174
"named" : false
3101
3175
},
3176
+ {
3177
+ "type" : " foreachelse" ,
3178
+ "named" : false
3179
+ },
3102
3180
{
3103
3181
"type" : " from" ,
3104
3182
"named" : false
You can’t perform that action at this time.
0 commit comments