Replies: 2 comments
-
The following is a debug dump of the token stream of the applied macro, which works when copied to the example code.
I've added it as second component in the test and pushed it to the repo for reference |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
hi, i need help with a macro i am working on, that is meant to be called from with in
rsx!()
i've been working on a proc macro crate to easily derive standard html dom attributes and events for custom components
the idea is to extend a Props
struct
easily, for exampleThere are three custom attributes and eventually two or three proc macros.
Attributes
#[attributes]
- which extends thestruct
definition with attributes,you can include:
href, id, class, etc.
div
basic, formatting, forms, frames, images, etc.
,global
attributesyou can use an
optional
list to make the fields optional and decorated with a#[props(optional)]
attributeyou can use a
default
list to use defaults or assign specific defaults, i.e.#[attributes(default(disabled = true))]
you can use an
exclude
list to skip individual attributes from the listEvents
#[events]
- which extends thestruct
definition with eventsyou can include:
onclick, onkeypress , etc.
keyboard, mouse, etc.
you can use an
exclude
list to remove individual attributes from the list* as i write this, i realize i could add support for all events of a tag too
Classes
#[classes]
- marks fields on thestruct
to be included in the implementedDisplay
trait of thestruct
intended to be rendered in theclass
attribute in the component.* I'm not convinced this implementation is clear/logical and will consider a better alternative if anyone has a suggestion.
Based on Standards
i created another crate to parse the html standard to ensure that only html 5 attributes and events can be specified
Apply Attributes
apply_attributes!
- is intended to tie it all to getter and apply fields to an internal html tag of your choosing, even spreading the values are to multiple tags.and this is where i need help ...
parsing seems to be working
i'm having issues tokenizing, for the example above i get the following compile error
i am tokenizing the individual fields as if i'm writing them by hand and i guess the order of how
rsx!
runs nested macros might affect this, but i am not really sure where to go from here.your help with this would be amazing, thanks
the repo is here dioxus-sugar
The
master
branches works for all three attribute macros described above, the code in question is in the branchfeature\apply_attributes_macro
Beta Was this translation helpful? Give feedback.
All reactions