it:ad:nvelocity:howto:compile_templates

IT:AD:NVelocity:HowTo:Compile Templates

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"}}
                };

  • /home/skysigal/public_html/data/pages/it/ad/nvelocity/howto/compile_templates.txt
  • Last modified: 2023/11/04 01:52
  • by 127.0.0.1