TextTemplate Overview !

TextTemplate is a class library, written in C# for .NET 3.5 and 4.0.

The library allows you to execute templates, containing both static text as well as executable code, and collects the combined output from the template.

You can think of a template as an old style ASP page, similar in nature to PHP or Perl execution.

Here is a simple example of such a template:

The current date and time is: <%= DateTime.Now %>.

Let's count from 1 to 5:
<% for (int index = 1; index <= 5; index++) { %>
  <%= index %>
<% } %>

When executed, the above template would generate something akin to:

The current date and time is: 20.01.2011 23:21:24.

Let's count from 1 to 5:
  1
  2
  3
  4
  5

Last edited Jan 20, 2011 at 9:22 PM by lassevk, version 4

Comments

No comments yet.