for example the A.razortemplate
<html>
<title>@Page.Title</title>
<keywords>@Page.Title</keywords>
<body>
crumb:<a href="">@Page.Title</a>><a href="">@Post.Title</a>
<h3>@Post.Title<h3>
@Post.Body
by-@User.PostAuthor
</body>
</html>
the above code in the one template(A),it include three @Model object that @Page,@Post,@User.i read the RazorEngine code,find just can pass one @Model patameter to the template,the following code from RazorEngine project.
protected virtual ITemplate CreateTemplate<T>(Type templateType, T model)
{
var instance = CreateTemplate(templateType);
SetModel(instance, model);
return instance;
}
i hated only just can pass one @Model,i need to some more flexible method,i can remove crumb statement from template at anytime,can add time of the post.
for the above problem,may be i can create a new class and create three propertys for @page,@post,@user,i think it not perfect solution.
by the way,i want to take the RazorEngine as the front-end template(like a string template etc.),the ASP.NET as back-end just do sql operation and pass data to front-end.someone can give some suggest?thanks.
RazorEngine uses a singular
Modelproperty be default. This property can be any type you like, so why not create a composite model:That way you can pass a singular model, and access the properties as: