-
-
Notifications
You must be signed in to change notification settings - Fork 440
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
Guidance on nested layouts and renderers #1899
Comments
Hi @bruceharrison1984 ! Actually, I didn't take private renderer: Renderer = (content: string | Promise<string>) => this.html(content)
// ...
render: Renderer = (...args: any[]) => this.renderer(...args) I'm thinking about it, but if you come up with a good way to nest layouts, please share! By the way, Sonik's |
Yeah, that's a tough one. I presume Sonik works via Vite scanning for layouts higher in the tree and merging them, while Hono doesn't have that same mechanism. You'd need some way to reference a parent Hono instance from the child to check if a Renderer has been registered. |
After thinking about this a bit, it seems like at a minimum you'd need to make the Line 107 in ff34b1b
Simply adding a |
Great! If you can, please create a PR that does this and write the specific usage in the description section of that PR. I want this to be a feature of the next major version of v4, so please make a PR based on this https://github.com/honojs/hono/tree/v4 Thanks. |
@yusukebe I'll give it a crack! No promises though 😆 |
Resolved by #1945 |
What is the feature you are proposing?
It'd be helpful if some documentation around nested layouts was available.
Currently doing something like the following doesn't work:
Currently, which ever renderer is located closest to the route is the one that will be used. Simply using JSX components to wrap a layout around pages works well enough, but a best practice would be helpful.
SonikJS supports nested layouts in this fashion (at least via __layout) so it would seem that Hono could also support this.
The text was updated successfully, but these errors were encountered: