00001 using System;
00002 using System.IO;
00003 using System.Collections;
00004 using System.Collections.Generic;
00005 using System.Text;
00006 using NVelocity;
00007 using NVelocity.App;
00008 using NVelocity.Context;
00009
00010 namespace MarekMailSystem2
00011 {
00012 public class TemplateEngine : VelocityEngine
00013 {
00014 public TemplateEngine(bool cacheTemplate)
00015 : base()
00016 {
00017 this.SetProperty("assembly.resource.loader.cache", cacheTemplate.ToString().ToLower());
00018 this.Init();
00019
00020 }
00021
00022
00023 public string Process(Dictionary<string, string> context, string template)
00024 {
00025 if (template == null) return null;
00026 if (template == "") return "";
00027 StringWriter writer = new StringWriter();
00028 this.Evaluate(new VelocityContext(new Hashtable(context)), writer, "mystring", template);
00029
00030 return writer.ToString();
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 }
00043 }
00044 }