-
-
Notifications
You must be signed in to change notification settings - Fork 313
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
Askama #70
Comments
Wow, thanks for getting back to me on this. Yes, I got the mechanics finally figured out. I got it working only by having the trait, the proc macro and the test in three different crates. The part about the testing was mostly the part I was missing in syn's README, which is otherwise awesome and almost got me where I needed to be. Also, I was looking for some hints on debugging proc macros, which I did not find in syn's README or docs (though of course I might have missed it). I finally stumbled upon -Z unstable-options --pretty expanded, which was really helpful in figuring out the mechanics. However, after this I ran into something more fundamental, which is that I can't figured out how to link the template struct to the on-disk template file. I filed rust-lang/rust#38546 about this; any ideas? |
Good call, I will add some notes about testing here until we get official Macros 1.1 documentation.
There is also the
I don't know of a reliable way to do this. Heuristics based on the current working directory might be your best bet. I remember Vulkano was thinking of doing something similar for GLSL shaders: https://github.com/tomaka/vulkano/issues/256#issuecomment-246171028, might be worth checking whether they have a solution. |
I added readme sections about testing and debugging. Thanks for the feedback! |
Ohh, Do you know if the cwd can be relied upon to always be the crate root, at least when using Cargo? Another option could be to define a |
Oh Cargo environment variables might be what we're looking for. I tried this: my_proc/src/lib.rs
testing/src/main.rs
And it prints out the path to the directory containing |
Yup, that will do for now. Thank you so much for the support! |
From IRC:
@djc did you get this figured out? I see some new commits in https://github.com/djc/askama but want to make sure you aren't still stuck.
Macros 1.1 has a restriction that a proc macro defined in a crate cannot be used in that same crate, so that is probably where this went wrong.
I see that you made a separate askama_test crate so hopefully that works better. Another option is what serde_derive does which is keep tests in a
tests
subdirectory.The text was updated successfully, but these errors were encountered: