toddams / RazorLight

Template engine based on Microsoft's Razor parsing engine for .NET Core
Apache License 2.0
1.5k stars 259 forks source link

Inject page to @RenderBody programmatically #524

Open bretbas opened 1 year ago

bretbas commented 1 year ago

Hi all. Im new in RazorLight, so don't throw tomatoes) I have a several templates with pages in db. Each template consists of string Layout (cshtml with @RenderBody) and several pages (with ViewContent cshtml).

I want to collect Layout with needed page (ViewContent), but i don't know how. So, i want to inject ViewContent of the page to Layout (@RenderBody)

var layout = await engine.CompileRenderAsync(template.Layout, (dynamic?)null);
var viewContent = await engine.CompileRenderAsync(page.ViewContent, (dynamic?)null);

How can i to do this?

devopsalexandr commented 1 year ago

I have the same problem

bretbas commented 1 year ago

Enybody knows how to do that or not? This lib can help?

bretbas commented 1 year ago

Is the project alive or not?