-
Notifications
You must be signed in to change notification settings - Fork 24
Add @with_children
decorator
#113
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
Conversation
b1045ad
to
552c90b
Compare
I went ahead and added a suggestion for a new section in the docs, so we can get the disussion on that part rolling as well. |
Have you had the chance to have a look at this? |
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.
2debf78
to
3b9548f
Compare
Rebased on top of 25.5.0. |
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.
This looks good to me but would be happy if another @with_children
user reviewed it too :)
Thanks for having a second look! I know that @davepeck has this on his list 😇 |
49563d9
to
29cafc1
Compare
Rebased after merge of #119. |
cc @Majsvaffla |
@jodal This is great! I ripped out my home-spun One thing that might be worth documenting is how to layer context consumers and from dataclasses import dataclass
import htpy as h
@dataclass(frozen=True)
class User:
name: str
email: str
USER_CONTEXT: h.Context[User | None] = h.Context("user", default=None)
@h.with_children
@USER_CONTEXT.consumer
def UserCard(user: User | None, children: h.Node, *, extra: str) -> h.Renderable:
... I don't tend to use contexts personally, but there you have it. FWIW, I think PS: Sorry it took so long to get back to this. PyCon needed extra recovery time. :-) |
As discussed in pelme#98
4836f1e
to
f30f77d
Compare
4b23060
to
b279936
Compare
I've fixed the typo @Majsvaffla found and added a paragraph and an example about how to combine context consumers and |
awesome, thanks! 🙌 |
This adds the
@with_children
decorator as discussed in #98.I've kept the implementation in a file of its own, but imported it into the
htpy
namespace for easy usage.The docs have not been updated, as I wanted to get this out there for discussion and tweaks first.
TODO