public static TemplateEditModel FromDomain(Template t)
 {
     return new TemplateEditModel {
         Name = t.Name,
         Subject = t.Subject,
         Content = t.Content,
     };
 }
Exemplo n.º 2
0
 public void Template_engine_performs_data_replacements()
 {
     var service = new BasicTemplateService();
     var t = new Template { Content = @"This is a {foo}." };
     var d = new TemplateData {{ "foo", "bar" }};
     var w = service.Render(t.Content, d, null);
     Assert.That(w, Is.EqualTo(@"This is a bar."));
 }
Exemplo n.º 3
0
 public void Template_engine_performs_url_replacements_with_virtual_directory()
 {
     var service = new BasicTemplateService();
     var r = new MockRequest(new Uri("http://sandbox.ascendrewards.com/bar/admin/foo"), "/bar");
     var t = new Template { Content = @"This is a <a href=""~/url"">link</a>." };
     var d = new TemplateData {{ "foo", "bar" }};
     var w = service.Render(t.Content, d, r);
     Assert.That(w, Is.EqualTo(@"This is a <a href=""http://sandbox.ascendrewards.com/bar/url"">link</a>."));
 }
Exemplo n.º 4
0
 public Template LoadTemplate(string id, string file)
 {
     if (!Cache.ContainsKey(id))
     {
         var t = Templates.TryGet(id);
         if (null == t)
         {
             // load from disk
             t = new Template();
             using (var reader = File.OpenText(file))
             {
                 t.Subject = reader.ReadLine();
                 t.Content = reader.ReadToEnd();
             }
         }
         Cache.Put(id, t, TimeSpan.FromHours(1));
     }
     return Cache.Get<Template>(id);
 }
 public void Apply(Template t)
 {
     t.Name = Name;
     t.Subject = Subject;
     t.Content = Content;
 }