IT:AD:NVelocity:HowTo:Compile Templates
Summary
Process
Assuming you have
body.nv:
#parse ("Header.nv")
Hi3 $Context.name,
This output has been generated on $Context.date.
<ul>
#foreach ($item in $Context.dict)
<li>$item.Value</li>
</ul>
#end
#if ( $Context.dict.Values.Count > 1 )
<p>Cool...</p>
#else
<p>BUmmer</p>
#end
referencing Header.nv:
<h1>$Context.headerText</h1>
#parse ("Parts/SubHeader.nv")
which in turn references SubHeader.nv:
<h1>$Context.subHeader</h1>
You can then pass it a model of
var viewModel = new
{
headerText = "AHEADER!!!",
subHeader="foo bar foo...",
name = "John", date = DateTime.Now,
dict=new Dictionary<string,string> {{"AKey","AValue"},{"BKey","BValue"}}
};