feat: add an unhygenic render macro (#556)

* feat: add an unhygenic render macro

* chore: use render instead of rsx!(cx,
This commit is contained in:
Jon Kelley authored and GitHub committed 2022-09-25 01:05:16 -07:00
1 parent 0c48cb3601
commit 28fba42e7e
28 files changed
+158 -163

No files matched your search

+20
View File
@@ -72,6 +72,26 @@ pub fn rsx(s: TokenStream) -> TokenStream {
}
}
/// The render! macro makes it easy for developers to write jsx-style markup in their components.
///
/// The render macro automatically renders rsx - making it unhygenic.
///
/// ## Complete Reference Guide:
/// ```ignore
#[doc = include_str!("../../../examples/rsx_usage.rs")]
/// ```
#[proc_macro]
pub fn render(s: TokenStream) -> TokenStream {
match syn::parse::<rsx::CallBody>(s) {
Err(err) => err.to_compile_error().into(),
Ok(body) => quote::quote! {
cx.render(#body)
}
.into_token_stream()
.into(),
}
}
/// Derive props for a component within the component definition.
///
/// This macro provides a simple transformation from `Scope<{}>` to `Scope<P>`,