public static Template FromStream(Stream stream, TemplateData data = null) { var template = new Template(data); template.Read(stream); return(template); }
// Static tools public static Template FromText(string text, TemplateData data = null) { var template = new Template(data); template.Parse(text); return(template); }
public static Template FromFile(string file, TemplateData data = null) { var template = new Template(data); template.Read(file); return(template); }
// Operations public void PushData(TemplateData data) { if (data == null) { throw new ArgumentNullException("data"); } _stack.Add(data); }
public string Render(TemplateData data = null) { var builder = new StringBuilder(); using (var writer = new StringWriter(builder)) Render(writer, data); return(builder.ToString()); }
public void Render(TextWriter writer, TemplateData data = null) { var context = new TemplateContext(this, writer); context.PushData(_global.Data); if (_data != null) { context.PushData(_data); } if (data != null) { context.PushData(data); } context.PushData(Data); _elements.Render(context); }
// Construction public Template(TemplateData data = null) : base(_global) { _data = data; }
public static string RenderFromStream(Stream stream, TemplateData data = null) { return(FromStream(stream, data).Render()); }
public static string RenderFromFile(string file, TemplateData data = null) { return(FromFile(file, data).Render()); }
public static string RenderFromText(string text, TemplateData data = null) { return(FromText(text, data).Render()); }