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 |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
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
structeasily, for exampleThere are three custom attributes and eventually two or three proc macros.
Attributes
#[attributes]- which extends thestructdefinition with attributes,you can include:
href, id, class, etc.divbasic, formatting, forms, frames, images, etc.,globalattributesyou can use an
optionallist to make the fields optional and decorated with a#[props(optional)]attributeyou can use a
defaultlist to use defaults or assign specific defaults, i.e.#[attributes(default(disabled = true))]you can use an
excludelist to skip individual attributes from the listEvents
#[events]- which extends thestructdefinition with eventsyou can include:
onclick, onkeypress , etc.keyboard, mouse, etc.you can use an
excludelist 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 thestructto be included in the implementedDisplaytrait of thestructintended to be rendered in theclassattribute 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
masterbranches works for all three attribute macros described above, the code in question is in the branchfeature\apply_attributes_macroAll reactions