|
@@ -84,10 +84,13 @@ impl CallBody {
|
|
|
location: Some(location),
|
|
|
};
|
|
|
|
|
|
+ // Empty templates just are placeholders for "none"
|
|
|
+ if self.roots.is_empty() {
|
|
|
+ return quote! { None };
|
|
|
+ }
|
|
|
+
|
|
|
quote! {
|
|
|
- Some({
|
|
|
- #body
|
|
|
- })
|
|
|
+ Some({ #body })
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -110,20 +113,20 @@ impl Parse for CallBody {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-#[derive(Default, Debug)]
|
|
|
-pub struct RenderCallBody(pub CallBody);
|
|
|
-
|
|
|
-impl ToTokens for RenderCallBody {
|
|
|
+impl ToTokens for CallBody {
|
|
|
fn to_tokens(&self, out_tokens: &mut TokenStream2) {
|
|
|
let body: TemplateRenderer = TemplateRenderer {
|
|
|
- roots: &self.0.roots,
|
|
|
+ roots: &self.roots,
|
|
|
location: None,
|
|
|
};
|
|
|
|
|
|
+ // Empty templates just are placeholders for "none"
|
|
|
+ if self.roots.is_empty() {
|
|
|
+ return out_tokens.append_all(quote! { None });
|
|
|
+ }
|
|
|
+
|
|
|
out_tokens.append_all(quote! {
|
|
|
- Some({
|
|
|
- #body
|
|
|
- })
|
|
|
+ Some({ #body })
|
|
|
})
|
|
|
}
|
|
|
}
|
|
@@ -145,6 +148,7 @@ impl<'a> TemplateRenderer<'a> {
|
|
|
let mut context = DynamicContext::default();
|
|
|
|
|
|
let mut roots = Vec::new();
|
|
|
+
|
|
|
for (idx, root) in self.roots.iter().enumerate() {
|
|
|
context.current_path.push(idx as u8);
|
|
|
roots.push(context.update_node::<Ctx>(root, &mut mapping)?);
|