ComponentPro UltimateTemplateEngine

Loading template from file

Language Filter: AllSend comments on this topic to ComponentPro

This topic demonstrates how to load a template from a file.

To load a template from a string you should use LoadFromFile method of the TemplateEngine class, as shown in the following example: 

Template.tpl
{%bool flag = true/}
{%if flag == true%}

Generated by $name$

{%else%}

Flag is set to False

{$if%}

The output will be:

Generated by UltimateTemplateEngine

using System;
using ComponentPro;

...

TemplateEngine dt = new TemplateEngine();
dt.LoadFromFile("Template.tpl");
string output = dt.Run();
Console.WriteLine(output);