feat!: use macro call name for scss module name in usey

This commit is contained in:
Yiffy Dev 2024-11-02 09:56:15 +05:00
commit a379035f79
No known key found for this signature in database
GPG key ID: FB83DFEAFB3F4709
2 changed files with 95 additions and 4 deletions

View file

@ -28,7 +28,6 @@ pub fn sassy_macro_impl(input: TokenStream) -> TokenStream {
}
let sourcesass = code.to_string();
let identname = ident.to_string();
let macro_doc = format!("Arbitrary {:?} code declared with `sassy!`. Pretty usable in tandem with `usey!` and `magic()` at build time", mode);
quote! {
@ -36,7 +35,6 @@ pub fn sassy_macro_impl(input: TokenStream) -> TokenStream {
#[macro_export]
macro_rules! #ident {
() => {#sourcesass};
(module) => {#identname};
(syntax) => {#mode};
}
}

View file

@ -34,7 +34,11 @@ impl StyleCall {
let call_bang = &self.call.bang_token;
// the following calls are expected by macro genereted by `sassy!`
let call_syntax = quote! {#call_path #call_bang (syntax)};
let call_file = quote! {#call_path #call_bang (module)};
let module_name = call_path
.get_ident()
.expect("BUG: failed to get identifier for macro call")
.to_string();
if self.vis_pub {
quote! {
@ -42,7 +46,7 @@ impl StyleCall {
}
} else {
quote! {
(format!("{}.{}", #call_file, #call_syntax), #call_code .to_string())
(format!("{}.{}", #module_name, #call_syntax), #call_code .to_string())
}
}
}