Templating engine–razor

Am nevoie de un templating engine pe Razor. Foloseam inainte http://stringtemplate.org/   -dar as vrea sa pot  scrie cod inainte – macar sa testez if(x == 1)
Am luat la puricat net-ul si am gasit

  1. https://github.com/Antaris/RazorEngine
  2. https://github.com/RickStrahl/Westwind.RazorHosting
  3. https://github.com/anurse/MicroRazorHost
  4. https://github.com/volkovku/RazorTemplates
  5. http://buildstarted.com/2010/09/29/razor-view-engine-without-mvc-at-all/
  6. https://github.com/jlamfers/RazorMachine

 

Alegerea nu e simpla. Insa , pentru mine , cistigatorul este 2. E singurul care mi-a aratat ca poate sa aiba  alte template-uri incluse:

@RenderPartial("~/Header_Partial.cshtml",Model)

 

Concluzia: Daca veti face un pachet software, aveti grija cum scrieti help-ul Winking smile

( Eu oi fi scris bine pentru http://youtu.be/wjkoMs98Z8U ?)

 

PS:

Stiu ca m-am mai luptat cu 1 – ca sa pot sa am “include”  – de ex:

Hello @Model.Name @Include("DepartLine",new { dept = Model.dept, i=1})

 

public class RezolverFile : ITemplateResolver     {         private string PathFiles;         public RezolverFile(string pathFiles)         {             this.PathFiles = pathFiles;         }         public string Resolve(string name)         {             return File.ReadAllText(Path.Combine(PathFiles, name+".txt"));         }     }     class TSFIleCOnfig : TemplateServiceConfiguration     {         public TSFIleCOnfig(string PathFiles)             : base()         {             base.Resolver = new RezolverFile(PathFiles);         }              }     class TS : TemplateService     {         public TS()             : base(new TSFIleCOnfig(Directory.GetCurrentDirectory()))         {                      }         public string RunFile<T>(T Model)         {             return RunFile(typeof(T).Name, Model);         }         public string RunFile<T>(string NameFile, T Model)         {             var template = base.CreateTemplate<T>("@Include(\"" + NameFile + "\")", Model);             return base.Run(template);         }              }

Leave a Reply

Your email address will not be published. Required fields are marked *