.NET Razor engine - Implementing layouts

前端 未结 1 934
渐次进展
渐次进展 2021-02-07 08:38

I\'m using the following snippet to enable Razor templating in my solution (outside of ASP.NET MVC3). Is it possible to easily implement layouts?

Background in

1条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-07 09:21

    I'm currently working on something very similar. It is a front end templating framework based on Nancy. I extended the Nancy's Razor implementation by Phil Haack. I have managed to get Partials, Templated Helpers and Layouts working.

    To render the layout I have a Layout property and inside the layout I have a content placeholder "{{content}}". So when I render the view if the Layout property is set I render the layout and then replace the content placeholder.

    The project is called Appia. Have a look at the sample views.

    Here is my baseView implementationbaseView implementation and here is the view engine code. It borrows a lot from the MVC Razor implementation and also has some Nancy specific stuff but it shouldn't be too hard to figure out what's happening.

    0 讨论(0)
提交回复
热议问题