Feb 1, 2011 at 12:46 PM


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

Feb 1, 2011 at 2:39 PM


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 2:44 PM

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

Feb 1, 2011 at 4: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" });