Ejemplo n.º 1
0
 public override IProcessResult Process(string filePath, string content)
 {
     var compiler = new HoganCompiler();
     string template = compiler.Compile(content);
     string templateName = Path.GetFileName(filePath).Split('.').First();
     var sb = new StringBuilder();
     sb.AppendLine("var JST = JST || {};");
     sb.AppendLine("JST['" + templateName + "'] = new Hogan.Template(" + template + ");");
     return new ProcessResult(sb.ToString());
 }
Ejemplo n.º 2
0
 public override IProcessResult Process(string filePath, string content)
 {
     var compiler = new HoganCompiler();
     string renderFunc = compiler.Compile(content);
     string templateName = Path.GetFileName(filePath).Split('.').First();
     string templateHtml = string.Join("\\r\"+\"\\n",
                            content.Replace("\"", "\\\"").Split(new[] {Environment.NewLine}, StringSplitOptions.None));
     var sb = new StringBuilder();
     sb.AppendLine("var JST = JST || {};");
     sb.AppendLine("JST['" + templateName + "'] = new Hogan.Template(" + renderFunc + ",\"" + templateHtml + "\",Hogan,{});");
     return new ProcessResult(sb.ToString());
 }
Ejemplo n.º 3
0
 public void CompileFailsGracefullyOnMono()
 {
     var compiler = new HoganCompiler();
     var exception = Assert.Throws(typeof(NotSupportedException), () => compiler.Compile(""));
     Assert.AreEqual("Hogan not yet supported for mono.", exception.Message);
 }