Skip to content
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

Docs: @with_children UI component pattern #8

Closed
wants to merge 1 commit into from
Closed

Conversation

bessey
Copy link

@bessey bessey commented Mar 30, 2024

Add documentation for the pattern described in #6 (comment)

I've tried to make the example consistent with the patterns in the other examples (namely, importing each element individually rather than import htpy as h).

Wasn't sure if this should live in docs/ or examples/ or both.

@bessey
Copy link
Author

bessey commented Mar 30, 2024

Ah, actually this example doesn't work quite how I envisioned. It requires that you call the function, as opposed to e.g. htpy.div where you can either htpy.div()[] or htpy.div[].

I guess that's unavoidable while using a decorator, since we must return a function which must be called. Is that right @pelme?

@pelme
Copy link
Owner

pelme commented Mar 31, 2024

I think you could implement __call__() on _ChildrenWrapper to support both patterns.

@bessey
Copy link
Author

bessey commented Apr 4, 2024

Makes sense. FYI right now I've moved on to dabbling with another side project so I don't expect to follow up with changes anytime soon

@pelme
Copy link
Owner

pelme commented Jun 25, 2024

Closing this PR since there is no activity/desire to keep working on it. Feel free to use this work for starting a new!

@pelme pelme closed this Jun 25, 2024
@davepeck
Copy link

Makes sense. I never fell in love with any of the patterns I played with for this.

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.

3 participants