File tree 2 files changed +29
-1
lines changed
2 files changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -236,11 +236,13 @@ impl TemplateBody {
236
236
237
237
// Assign paths to all nodes in the template
238
238
body. assign_paths_inner ( & nodes) ;
239
- body. validate_key ( ) ;
240
239
241
240
// And then save the roots
242
241
body. roots = nodes;
243
242
243
+ // Finally, validate the key
244
+ body. validate_key ( ) ;
245
+
244
246
body
245
247
}
246
248
Original file line number Diff line number Diff line change @@ -141,3 +141,29 @@ fn complex_kitchen_sink() {
141
141
142
142
let _cb: CallBody = syn:: parse2 ( item) . unwrap ( ) ;
143
143
}
144
+
145
+ #[ test]
146
+ fn key_must_be_formatted ( ) {
147
+ let item = quote:: quote! {
148
+ div {
149
+ key: value
150
+ }
151
+ } ;
152
+
153
+ let parsed = syn:: parse2 :: < CallBody > ( item) . unwrap ( ) ;
154
+ println ! ( "{:?}" , parsed. body. diagnostics) ;
155
+ assert ! ( !parsed. body. diagnostics. is_empty( ) ) ;
156
+ }
157
+
158
+ #[ test]
159
+ fn key_cannot_be_static ( ) {
160
+ let item = quote:: quote! {
161
+ div {
162
+ key: "hello world"
163
+ }
164
+ } ;
165
+
166
+ let parsed = syn:: parse2 :: < CallBody > ( item) . unwrap ( ) ;
167
+ println ! ( "{:?}" , parsed. body. diagnostics) ;
168
+ assert ! ( !parsed. body. diagnostics. is_empty( ) ) ;
169
+ }
You can’t perform that action at this time.
0 commit comments