-
Notifications
You must be signed in to change notification settings - Fork 7
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
Layout support #6
Comments
Hello, There is currently no layout support just like in ASP.NET, but that's a useful feature I suppose I should add eventually. However, you can work around this limitation by writing two template files such as @(new Header())
My content!
@(new Footer()) This doesn't handle sections, but similar workarounds should be possible for them by passing parameters to the |
This is a neat project. I've only just found this project so I'm not as familiar with all of the details, but from the type definitions I see, you could provide a efficient version of this for simple layout templates as follows:
The base definitions are changed slightly:
The render procedure for a template then executes these "inside-out":
where the This only supports a single template-body distinction, but it could possibly later be extended to provide full section support by changing the As a brief aside, it would be helpful to have a more detailed breakdown or comparison of RazorBlade to Razor slices which seems to have a similar goal, but slightly different design tradeoffs. |
Thanks! 🙂 Yes, I considered implementing something like I added a writer stack on another branch (07a829a) which could be useful for layouts. I'd also like to have full section support initially. I just need to find some time to work on this. There are many existing Razor libraries, but I wasn't aware of RazorSlices. I wrote RazorBlade because I wanted two things I couldn't find elsewhere:
|
I've added full support for layouts and sections in v0.5.0, enjoy! 🙂 |
Hi, i was playing around with this package and cannot figure out how would i make a .cshtml with Layout support? So i want to have two .cshtml and one of them would be a wrapper for the other.
e.g. in classic razor pages we are able to do in layout (lets call it SimpleLayout.cshtml)
and then in view:
so the actual result would be:
Greetings!
The text was updated successfully, but these errors were encountered: