8000 Add the callback attribute by grego · Pull Request #56 · maciejhirsz/ramhorns · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add the callback attribute #56

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

Merged
merged 2 commits into from
Dec 13, 2021
Merged

Conversation

grego
Copy link
Contributor
@grego grego commented Dec 3, 2021

A new attribute callback is added, to be used as #[ramhorns(callback = "some_fn").
For a field of type T, it allows one to pass a function of type (&T, &mut E) -> Result<(), E::Error)> where E: Encoder to customise the rendering of the field.

#[md] attribute is replaced with #[ramhorns(md)] for clarity and consistency with other attributes.
render_cmark method is deleted as it no longer serves a purpose (a callback is used instead).

A new attribute `callback` is added, to be used as `#[ramhorns(callback = "some_fn")`.
For a field of type `T`, it allows one to pass a function of type
`(&T, &mut E) -> Result<(), E::Error)>` where `E: Encoder` to customise
the rendering of the field.

`#[md]` attribute is replaced with `#[ramhorns(md)]` for clarity and consistency
with other attributes.
`render_cmark` method is deleted as it no longer serves a purpose (a callback
is used instead).
@maciejhirsz
Copy link
Owner

Hey @grego, will do a review later today, just a quick note that I think it would be better to do #[ramhorns(callback = some_fn)] with a raw ident, partly for readability, partly because it lets you us pass the correct span on call site in case there are some compile issues. I can do that later on my own if need be.

@grego
Copy link
Contributor Author
grego commented Dec 13, 2021

Sure, that's a good idea.

Change the syntax to `ramhorns(callback(some_fn))`.
@grego
Copy link
Contributor Author
grego commented Dec 13, 2021

As syn::MetaNameValue must contain a literal after =, I've changed the syntax to #[ramhorns(callback(some_fn))] where a raw ident can be used.

@maciejhirsz
Copy link
Owner

Yeah, it needs some manual work there, I'll give it a go in the morning, cheers :)

@maciejhirsz maciejhirsz merged commit 598239b into maciejhirsz:master Dec 13, 2021
@grego
Copy link
Contributor Author
grego commented Dec 14, 2021

Please also bump the pulldown_cmark dependency to 0.8.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0