@@ -52,6 +52,8 @@ pub enum HtmlType {
5252 If ,
5353 For ,
5454 Match ,
55+ Break ,
56+ Continue ,
5557 Empty ,
5658}
5759
@@ -64,6 +66,8 @@ pub enum HtmlTree {
6466 For ( Box < HtmlFor > ) ,
6567 Match ( Box < HtmlMatch > ) ,
6668 Node ( Box < HtmlNode > ) ,
69+ Break ( Token ! [ break ] ) ,
70+ Continue ( Token ! [ continue ] ) ,
6771 Empty ,
6872}
6973
@@ -80,6 +84,8 @@ impl Parse for HtmlTree {
8084 HtmlType :: If => Self :: If ( Box :: new ( input. parse ( ) ?) ) ,
8185 HtmlType :: For => Self :: For ( Box :: new ( input. parse ( ) ?) ) ,
8286 HtmlType :: Match => Self :: Match ( Box :: new ( input. parse ( ) ?) ) ,
87+ HtmlType :: Break => Self :: Break ( input. parse ( ) ?) ,
88+ HtmlType :: Continue => Self :: Continue ( input. parse ( ) ?) ,
8389 } )
8490 }
8591}
@@ -113,6 +119,14 @@ impl HtmlTree {
113119 Some ( HtmlType :: For )
114120 } else if HtmlMatch :: peek ( cursor) . is_some ( ) {
115121 Some ( HtmlType :: Match )
122+ } else if cursor. ident ( ) . map ( |( i, _) | i == "break" ) . unwrap_or ( false ) {
123+ Some ( HtmlType :: Break )
124+ } else if cursor
125+ . ident ( )
126+ . map ( |( i, _) | i == "continue" )
127+ . unwrap_or ( false )
128+ {
129+ Some ( HtmlType :: Continue )
116130 } else if input. peek ( Token ! [ <] ) {
117131 let _lt: Token ! [ <] = input. parse ( ) . ok ( ) ?;
118132
@@ -163,6 +177,8 @@ impl ToTokens for HtmlTree {
163177 Self :: For ( block) => block. to_tokens ( tokens) ,
164178 Self :: Match ( block) => block. to_tokens ( tokens) ,
165179 Self :: Node ( node) => node. to_tokens ( tokens) ,
180+ Self :: Break ( token) => token. to_tokens ( tokens) ,
181+ Self :: Continue ( token) => token. to_tokens ( tokens) ,
166182 }
167183 }
168184}
@@ -428,7 +444,12 @@ impl HtmlChildrenTree {
428444 HtmlNode :: Expression ( _) => None ,
429445 } ;
430446 }
431- HtmlTree :: If ( _) | HtmlTree :: For ( _) | HtmlTree :: Match ( _) | HtmlTree :: Empty => {
447+ HtmlTree :: If ( _)
448+ | HtmlTree :: For ( _)
449+ | HtmlTree :: Match ( _)
450+ | HtmlTree :: Break ( _)
451+ | HtmlTree :: Continue ( _)
452+ | HtmlTree :: Empty => {
432453 return Some ( false ) ;
433454 }
434455 }
0 commit comments