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

@component children #139

Closed
jamesdbrock opened this issue Apr 29, 2024 · 0 comments · Fixed by #148
Closed

@component children #139

jamesdbrock opened this issue Apr 29, 2024 · 0 comments · Fixed by #148

Comments

@jamesdbrock
Copy link
Member

We would like to be able to write a @component which can have children.

In React, this is done by “the special children prop to pass children elements directly into their output.” https://legacy.reactjs.org/docs/composition-vs-inheritance.html#containment

Edifice doesn't currently have any way to do that. The best we've got is that we can use a @contextmanager decorated function to yield and then render children.

from contextlib import contextmanager

@contextmanager
def TrailComponent():
    """
    Example::

        with TrailComponent():
            TrailMain()
            TrailDivider()
            TrailProject()
    """
    with View():
        yield
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 a pull request may close this issue.

1 participant