-
Notifications
You must be signed in to change notification settings - Fork 92
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
Support for implementing @section, @RenderSection #73
base: master
Are you sure you want to change the base?
Conversation
@adoconnection, will you accept this PR? I currently have a fork of this repo plus this update because of our broad @section use. It would be very useful to have this accepted into the main project. Thanks! |
Hi @ItWorksOnMyMachine could you please share how exactly are you using it? Must be something similar to web server where you render generic template with random Layout + sections, right? Are you on NET6+ ? For ASP.NET MVC there is strong reason Layout and Section are located in cshtml files: since controller is not resonsible for templating, cshtml file is the only place you can choose layout. For RazorEngineCore on the other hand there is no files, so RazorEngineCore will have to go somewhere to grab Layout, it seems like a overcomlication. Making ProjectEngineBuilderAction accessable seems to be good improvement. |
Hi @adoconnection, We are transitioning from net48 to net6 and the final bits that use net48 are from Antaris RazorEngine. We use this to generate emails for our customers. We have about 100(ish) different email templates and 10 or so different layouts we use depending on customer type. Most of these layouts use RenderSection() to include email specific html if/when relevant. Around 30 of our emails include an @section directive for things like custom login buttons and other header bits that are unique to specific user types. I forked this repo and applied this PR and everything works fine. I suppose just adding access to ProjectEngineBuilderAction would allow all of this to be done in a custom template implementation. So, perhaps that's a better solution considering how little template support you want to add directly? |
@adoconnection, any thoughts on making ProjectEngineBuilderAction public? Support for sections can be left out if ProjectEngineBuilderAction is public because we can then provide our own support in our Templates. I'm currently maintaining a fork of this project just so I can access ProjectEngineBuilderAction in order to do just this. |
Hi @ItWorksOnMyMachine, ProjectEngineBuilderAction should go public for sure 👍👍 |
I've create a new PR with just this and no extra functionality. #141 |
These changes allow implementation of templates supporting @section and @RenderSection, which are quite widely used in razor documents, so that support may be needed if porting existing apps to RazorEngineCore. Includes an example based on the layout example at https://github.com/adoconnection/RazorEngineCore/wiki/@Include-and-@Layout (run LayoutAndSections.Test )