# IT:AD:NVelocity:HowTo:Compile Templates #
* [[../|(UP)]]
{{indexmenu>.#2|nsort tsort}}
## Process ##
Assuming you have
body.nv:
#parse ("Header.nv")
Hi3 $Context.name,
This output has been generated on $Context.date.
#foreach ($item in $Context.dict)
- $item.Value
#end
#if ( $Context.dict.Values.Count > 1 )
Cool...
#else
BUmmer
#end
referencing `Header.nv`:
$Context.headerText
#parse ("Parts/SubHeader.nv")
which in turn references `SubHeader.nv`:
$Context.subHeader
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 {{"AKey","AValue"},{"BKey","BValue"}}
};
## Resources ##
* http://auctivacommerce.com/help/entry.aspx?id=An-introduction-to-NVelocity-for-custom-email-template-design
* https://chrisseroka.wordpress.com/2013/08/01/generating-html-document-from-template-using-nvelocity/
* http://www.codeproject.com/Articles/12751/Template-merging-with-NVelocity-and-ASP-NET