Home

Vici Core - Template Engine - Basics

Documentation is in the works, but here are simple examples of the expression parser and template engine:

Example of a template (using Velocity syntax):

<table>
#foreach ($product in $Products)
   <tr><td>$product.Name</td>
   #if ($product.Stock > 0)
      <td>In stock</td>
   #else
     <td>Backordered</td>
   #end
  </tr>
#end
</table>

The code to parse and render the template:

TemplateParser template = new TemplateParser<Velocity>();

IParserContext data = new CSharpContext();

data["Products"] = GetOrders(); // this funcion simply returns a list of order objects

string renderedFile = template.RenderFile("template.htm" , data);