ComponentPro UltimateTemplateEngine

Rendering template to a TextWriter object

See AlsoLanguage Filter: AllSend comments on this topic to ComponentPro

To direct the generated output string to a TextWriter object, you need to retrieve a reference to a TextWriter object and pass it to the Run method of the TemplateEngine class, as shown in the following example:

using System;
using System.IO;
using ComponentPro;


// Create a new StreamWrite that will be used to write the generated output string to output.txt file.
FileStream fs = new FileStream("output.txt", FileMode.Create);
StreamWriter sw = new StreamWriter(fs);

TemplateEngine dt = new TemplateEngine();
dt.LoadFromString("{%string str = \"hello \" + \"world\"/}$str$");


See Also

Using Template

Rendering template