You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
694 B
25 lines
694 B
using System; |
|
using System.Collections.Generic; |
|
using System.Text; |
|
|
|
namespace ReZero.TextTemplate |
|
{ |
|
public class TemplateEngine : ITemplateEngine |
|
{ |
|
private readonly Dictionary<string, IDirective> directives = new Dictionary<string, IDirective>(); |
|
|
|
public void AddDirective(string name, IDirective directive) |
|
{ |
|
directives[name] = directive; |
|
} |
|
|
|
public void Render(string template, object data, StringBuilder output) |
|
{ |
|
foreach (var directive in directives) |
|
{ |
|
template = directive.Value.Execute(template, data, this); |
|
} |
|
output.Append(template); |
|
} |
|
} |
|
}
|
|
|