Spark view engine - coming soon
June 12th, 2008Between GTA IV and working on the Spark view engine my blogging time on nights and weekends has been nearly squeezed out of existence.
So in between “real” posts here’s a quick preview about what’s coming up… Some syntax from the Spark view engine soon to be available to Asp.Net Mvc and Castle Project MonoRail.
If you’re especially curious there are some version 0.1 docs that show syntax.
And here are some fragments from a monorail demo site for an example.
homecontroller.cs
[Layout("Default")]
public class HomeController : SmartDispatcherController
{
public void Index()
{
}
public void Apply(string name, string address)
{
PropertyBag["caption"] = "Information submitted";
PropertyBag["message"] = string.Format("Name {0}, Address {1}", name, address);
PropertyBag["continue"] = new {controller="Home", action="Index"};
RenderSharedView("common/simplemessage");
}
}
home/index.xml
<h1>Hello world</h1>
<div>
$Form.FormTag(new {action="apply", method="get"});
<p>$DateTime.UtcNow;</p>
<p>Name: $Form.TextField("name");</p>
<p>
Address:
$Form.TextField("address", new {@class="w00t", style="margin-left:20px"});
</p>
<p>$Form.Submit("Apply");</p>
$Form.EndFormTag();
</div>
common/simplemessage.xml
<div>
<h3>$H(ViewData["caption"]);</h3>
<var link=’Url.Link("Continue", ViewData["continue"])’/>
<p>$link;</p>
<p>$H(ViewData["message"]);</p>
<p>$link;</p>
</div>
shared/default.xml
<html>
<head>
<use namespace="System"/>
<use namespace="Castle.MonoRail.Views.Spark"/>
<title>Hello</title>
$Ajax.InstallScripts();
</head>
<body>
<div id="header">
</div>
<div id="main">
<use content="view"/>
</div>
<div id="footer">
</div>
</body>
</html>