-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature request] Make a style! macro to write style directly in Rust files #9
Comments
I like this idea. This change itself should be relatively easy to implement with the current state of turf. To keep everything consistent, it should definitely respect turf's settings, and with #8 planned, it's important to discuss how the proposed What seems particularly interesting to me is what the files should be called that are output when a user decides to set the |
I can be the rust file name but with If you call the macro in To avoid these conflicts, the output can re-use the complete path so you if you have |
This is only possible on the nightly toolchain of Rust (see https://doc.rust-lang.org/proc_macro/struct.Span.html#method.source_file). Using this part of the Span api makes it necessary to hide this feature from users of stable Rust, which I don't want. An idea that came to my mind is using a hash (maybe of the resulting css style sheet?) as a file name. This makes every file name unique. However the names are quite ugly and can be harder to use. To make it easier to handle the resulting files, two new variables similar to the current |
Wouldn't it work with the A hash would be working but if some user want to use an external tool to build some CSS together after turf compiled files (and group some files by components/purpose), it would become difficult, I'm not sure this is suitable (also, I just saw noticed you completed #8, thank you, I will give it a try!) |
Macros are resolved in the file they are used in. This wouldn't work because if turf needs to read the macros output, |
Oh, right, I understand Unfortunately I have no other idea so I guess this won't be possible to have a "proper" filename |
@myFavShrimp it seems you also added this feature since 0.7.0, I tried it and it works as expected so I guess this issue can be closed? |
This feature is implemented and available when building from the repository but it is not released yet. You are right, this issue can be closed |
Hello,
A nice feature provided by some other CSS tools for Rust (styled and stylers) have a
style!
macro to allow writing CSS directly in.rs
files.Instead of using `style_sheet!("path/to/file.scss"), this would allow us to write directly:
Of course, this does not mean the
style_sheet!
macro should be remove, both can be complementary.The text was updated successfully, but these errors were encountered: