Hello, I've been working on an extremely simple view engine that isn't tied to MVC.
It's a bit rough around the edges right now but I would consider it usable, especially as an alternative to directly quoting HTML in C# code.
I'm waiting for a project page to be created for me over at
http://quokforge (soon to be BSDforge and not tied to OS development) and when that comes I'll provide a link.
But it's very simple. The basic flow is this:
Make a `templates/` directory in your project. Stick in the EViewBase.cs and EViewGenerator.tt file.
Make a sample HTML file like (named TestView.html) and put it in the `templates/` directory
<html>
<head>
<title>{=Title=}</title>
</head>
<body>
{@
SomeNumber as int;
@}
<!--just declare our SomeNumber variable as an integer instead of the default `string` -->
SomeNumber: {=SomeNumber=} <br />
{# //now we are in C# code
if(SomeNumber>10){
Write("Number is greater than 10!");
}
#}
</body>
</html>
Then run the T4 template engine and it will create EViewGenerator.cs which will contain your template translated to C#
Then to render it from your model(or whatever):
var view=new TestView();
view.Title="Our Test View";
view.SomeNumber=20;
response.Write(view.Render()); //render returns a simple string variable containing your HTML
I made this for a separate project but thinking back to here I knew you guys were in need of a view engine. I wouldn't say it's a complete solution but It's something to consider to make Manos a bit more friendly in this early stage.
Also it doesn't make any references to the System.Web namespaces. In fact, I test it by running it from a console project.
Tell me if you're interested and I'll provide a tarball of the source if I don't already have a project page by then.
--
--Earlz