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()); }
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()); }
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); }