<< Click to Display Table of Contents >> Navigation: Delphi HTML Report Library > Templates > Example of logical sections |
For example, we have a list of employees, some of whom have e-mails. Those names should be displayed as a link, and the rest – as a plain text. For this, data must contain a flag field with value of true or false. For example:
<list>
<employee name="Willis" email="bruce@hollywood.com" hasemail="true"/>
<employee name="Stallone" />
</list>
template:
{{#employee}}
{{#hasemail}
<a href="{{email}}">{{name}}</a><br/>
{{/hasemail}
{{^hasemail}
{{name}}<br/>
{{/hasemail}
{{/employee}}
Result:
Willis
Stallone
Other type of logical section is named section. For example we want to process following XML:
<main>
<section1>
…
</section1>
<section2>
…
</section2>
<section2>
…
</section2>
</main>
To apply template only to tags named section2 (and exclude section1) add ? before the section name:
{{#main}}
{{#?section2}}
…
{{/?section2}}
{{/main}}