public void Render(StreamWriter outputWriter, Dictionary <string, object> globals) { CompileCheck(globals); try { IRenderContext context = new RenderContext(); foreach (var item in globals) { context[item.Key] = item.Value; } context["__FormatResult"] = new Func <object, string>(FormatResult); context["__IsFalseResult"] = new Func <object, bool>(IsFalseResult); if (!context.ContainsKey("repeat")) { context["repeat"] = new RepeatDictionary(); } _templateInfo.RenderMethod.Invoke(null, new object[] { outputWriter, context }); } catch (TargetInvocationException ex) { throw new RenderTemplateException(_templateInfo, ex.InnerException.Message, ex.InnerException); } catch (Exception ex) { throw new RenderTemplateException(_templateInfo, ex.Message, ex); } }
public void Render(StreamWriter outputWriter, Dictionary<string, object> globals) { CompileCheck(globals); try { IRenderContext context = new RenderContext(); foreach (var item in globals) context[item.Key] = item.Value; context["__FormatResult"] = new Func<object, string>(FormatResult); context["__IsFalseResult"] = new Func<object, bool>(IsFalseResult); if (!context.ContainsKey("repeat")) context["repeat"] = new RepeatDictionary(); _templateInfo.RenderMethod.Invoke(null, new object[] { outputWriter, context }); } catch (TargetInvocationException ex) { throw new RenderTemplateException(_templateInfo, ex.InnerException.Message, ex.InnerException); } catch (Exception ex) { throw new RenderTemplateException(_templateInfo, ex.Message, ex); } }