masterpage

Feb 1, 2011 at 11:46 AM

Hi,

How I can to set the master page using the Razor Parse method?

Coordinator
Feb 1, 2011 at 1:39 PM

Hi,

RazorEngine does not currently support template layouts, but will do in future releases. Don't be confused with our RazorEngine project and ASP.NET MVC/WebPages + Razor. They are different things.


Feb 1, 2011 at 1:44 PM

So the solution is to write the content of the layout within the body template.

Coordinator
Feb 1, 2011 at 3:50 PM

As of v2 (current release is v2.1) we do support @Include which allows you to include subtemplates in the main template.  I'm currently looking at how to implement master templates in RazorEngine.

string template1 = "Hello @Model!";
Razor.CompileWithAnonymous(template1, "template1");

string template2 = "@Include(\"template1\", @Model.Name) Welcome to Razor";
string result = Razor.Parse(template2, new { Name = "World" });