RazorEngine string layouts and sections?

前端 未结 3 956
[愿得一人]
[愿得一人] 2020-12-24 03:09

I use razor engine like this:

public class EmailService : IService
{
    private readonly ITemplateService templateService;

    public EmailService(ITemplat         


        
3条回答
  •  滥情空心
    2020-12-24 03:38

    It looks like someone else solved it for you.

    https://github.com/aqueduct/Appia/blob/master/src/Aqueduct.Appia.Razor/RazorViewEngine.cs

    The code you want is in the second ExecuteView method. Though they're creating their own view engine, you can instead create your own custom templating solution and use something similar. Basically they are looking for the Layout property of the Template, and if it exists doing a search and replace for the content from the layout.

    Here is a link to RazorEngine's custom templating:

    http://razorengine.codeplex.com/wikipage?title=Building%20Custom%20Base%20Templates&referringTitle=Documentation

    Here is where I found your solution:

    .NET Razor engine - Implementing layouts

提交回复
热议问题