Spark Documentation
Basic markup
A view file has basic html markup that can appear pretty much as you'd expect.
<div> <p>Hello <span>world</span>!</p> </div>
Samples
list.xml
<viewdata
Category="Category"
Categories="IList[[Category]]"/>
<!-- Note - there is property Category of type Category
in the ViewData. It just looks like a typo. -->
<content name="leftColumn">
<h2>Categories</h2>
<ul>
<for each='var cat in Categories'>
<var isSelected='cat.CategoryID == Category.CategoryID'/>
<li style='${isSelected ? "font-weight:bold" : ""}'>
$Html.ActionLink[[ProductsController]](
p=>p.Category(cat.CategoryID),
cat.CategoryName);
</li>
</for>
</ul>
</content>
<h2>$Category.CategoryName;</h2>
<ul>
<for each="var product in Category.Products">
<Product/>
</for>
</ul>
<p>$Html.ActionLink("Add New Product", "New");</p>
_Product.xml
<li> $product.ProductName; <span class="editlink">$Html.ActionLink[[ProductsController]](c=>c.Edit(product.ProductID), "Edit");</span> </li>
Master template
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<viewdata Title="string"/>
<title>$Html.Encode(Title ?? "My Sample MVC Application");</title>
<link href="../../Content/Site.css" rel="stylesheet" type="text/css" />
<use namespace="MvcContrib.Samples.SparkViewEngine.Controllers"/>
<use namespace="MvcContrib.Samples.SparkViewEngine.Models"/>
<use namespace="System.Collections.Generic"/>
</head>
<body>
<div class="page">
<div id="header">
<p id="logo">
<a href="">$Html.Encode(Title ?? "My Sample MVC Application");</a>
</p>
<ul id="mainMenu">
<li>$Html.ActionLink("Home", "Index", "Home");</li>
<li>$Html.ActionLink("About", "About", "Home");</li>
<li>$Html.ActionLink[[ProductsController]](c=>c.Category(1), "Products");</li>
</ul>
</div>
<div id="mainContent">
<div class="columnsContainer">
<div class="leftColumn">
<use content="leftColumn"/>
</div>
<div class="rightColumn">
$Content["view"];
</div>
<div class="clear">
</div>
</div>
<div id="footer">
<p>
My Sample MVC Application © Copyright 2008
</p>
<ViewSource/>
</div>
</div>
</div>
</body>
</html>
_ViewSource.xml
<p>
<use namespace="MvcContrib.Samples.SparkViewEngine.Controllers"/>
$Html.ActionLink[[HomeController]](
c=>c.ViewSource(
ViewContext.RouteData.GetRequiredString("controller"),
ViewContext.ViewName,
ViewContext.MasterName),
"View source");
</p>
Misc added - needs documentation
Added controller and "application" as default master names in shared directoryAdditional <%=expression%> syntax addedInline csharp statements added with <%code%> or #codeAdded <macro name="Foo"></macro> function declaration- Added monorail specific support for view components
Added automatic index integer to for loopsSupport for 'literal' as "literal"- Removed $expression; syntax
Added <test if="expression"> and inline <else if="expression"/> and <else/>
