public String RenderToString(TemplateScope Scope = null) { if (Scope == null) Scope = new TemplateScope(); var StringWriter = new StringWriter(); Render(new TemplateContext(StringWriter, Scope, TemplateFactory)); return StringWriter.ToString(); }
public String RenderToString(TemplateScope Scope = null) { if (Scope == null) { Scope = new TemplateScope(); } var StringWriter = new StringWriter(); Render(new TemplateContext(StringWriter, Scope, TemplateFactory)); return(StringWriter.ToString()); }
public void TestTrueFalseNoneAreImmutableConstants() { var Scope = new TemplateScope(new Dictionary<String, object>() { { "true", false }, { "false", true }, { "none", 1 }, }); Assert.AreEqual("1", CompileTemplateCodeByString("{% if true %}1{% else %}0{% endif %}").RenderToString(Scope)); Assert.AreEqual("0", CompileTemplateCodeByString("{% if false %}1{% else %}0{% endif %}").RenderToString(Scope)); Assert.AreEqual("0", CompileTemplateCodeByString("{% if none %}1{% else %}0{% endif %}").RenderToString(Scope)); }
public TemplateContext(TextWriter Output, TemplateScope Scope = null, TemplateFactory TemplateFactory = null) { if (Scope == null) Scope = new TemplateScope(); this.Output = Output; this.Scope = Scope; this.TemplateFactory = TemplateFactory; Filters = new Dictionary<string, Tuple<Type, string>>(); AddFilterLibrary(typeof(CoreFilters)); }
public TemplateContext(TextWriter Output, TemplateScope Scope = null, TemplateFactory TemplateFactory = null) { if (Scope == null) { Scope = new TemplateScope(); } this.Output = Output; this.Scope = Scope; this.TemplateFactory = TemplateFactory; Filters = new Dictionary <string, Tuple <Type, string> >(); AddFilterLibrary(typeof(CoreFilters)); }
public String RenderToString(TemplateScope Scope = null) { if (Scope == null) { Scope = new TemplateScope(); } var StringWriter = new StringWriter(); #if NET_4_5 RenderAsync(new TemplateContext(StringWriter, Scope, TemplateFactory)).Wait(); #else Render(new TemplateContext(StringWriter, Scope, TemplateFactory)); #endif return(StringWriter.ToString()); }
public TemplateScope(TemplateScope ParentScope = null) { this.ParentScope = ParentScope; this.Items = new Dictionary <String, dynamic>(); }
public TemplateScope(Dictionary <String, dynamic> Items, TemplateScope ParentScope = null) { this.ParentScope = ParentScope; this.Items = Items; }
public void TestExecForElse() { var Params1 = new TemplateScope(new Dictionary<String, object>() { { "List", new int[] { 1, 2, 3, 4, 5 } } }); var Params2 = new TemplateScope(new Dictionary<String, object>() { { "List", new int[] { } } }); Assert.AreEqual("12345", CompileTemplateCodeByString("{% for Item in List %}{{ Item }}{% else %}Empty{% endfor %}").RenderToString(Params1)); Assert.AreEqual("Empty", CompileTemplateCodeByString("{% for Item in List %}{{ Item }}{% else %}Empty{% endfor %}").RenderToString(Params2)); }
public TemplateScope(TemplateScope ParentScope = null) { this.ParentScope = ParentScope; this.Items = new Dictionary<String, dynamic>(); }
public TemplateScope(Dictionary<String, dynamic> Items, TemplateScope ParentScope = null) { this.ParentScope = ParentScope; this.Items = Items; }
public void NewScope(Action Action) { this.Scope = new TemplateScope(this.Scope); Action(); this.Scope = this.Scope.ParentScope; }
public void NewScope(Action Action) { this.Scope = new TemplateScope(this.Scope); Action(); this.Scope = this.Scope.ParentScope; }
public String RenderToString(TemplateScope Scope = null) { if (Scope == null) Scope = new TemplateScope(); var StringWriter = new StringWriter(); #if NET_4_5 RenderAsync(new TemplateContext(StringWriter, Scope, TemplateFactory)).Wait(); #else Render(new TemplateContext(StringWriter, Scope, TemplateFactory)); #endif return StringWriter.ToString(); }