-
Notifications
You must be signed in to change notification settings - Fork 19
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
Add labels! and labels_sep_by! utility macros. #8
Conversation
I realized I forgot to create a branch. 😓 |
Nice!
😢 I was thinking of patterns. Oh well. |
($sep:expr; $item:expr) => {{ | ||
|
||
use $crate::Template; | ||
use $crate::RenderOnce; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of importing and calling, just use the fully qualified syntax: $crate::RenderOnce::render(&$item, tmpl)
Otherwise, you run the risk of running into conflicting functions.
Just a few nits and this looks good to go. |
I amended with documentation and suggested refactor. I also refactored the macros to add separator only if there is a previous label. This was an edge case I missed. |
3adb351
to
ab31702
Compare
/// | ||
/// This useful in generating class attribute as follows: | ||
/// | ||
/// ```norun |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why mark this norun?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I copied the doc comments from another macro and reworked it. I wasn't sure what norun
does. I can remove it if you like.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's because I've been lazy 😴. I just pushed a commit that removes the norun directives (so you can see how to do this). (...I also ended up having to fix many of the examples which is why norun should be avoided...).
I refactored and I reworked the docs a bit; hope it's less awkward :) |
Removing |
See the updated docs (where I've removed norun). Basically, you have to wrap your example:
The |
The new docs are great! Much better than I would have written, I hate writing docs... I'll merge after you fix the travis failure. |
I fixed the doctests and squashed the commits. I think we ironed out all the issues for this PR. |
Thank you! It was a pleasure working with you. |
Closes #7
I use suggestion from #7 (comment)
I added
labels_sep_by!
because I wanted to be able to customize delimiters. I use it to generate the style attribute of the element.@Stebalien I couldn't get this to work
labels!("active" if false)
since:according to https://doc.rust-lang.org/book/macros.html
Any suggestions?