public string TransformText(IEnumerable <KeyValuePair <string, object> > variables) { HxlTemplateContext ec = new HxlTemplateContext(this); ec.Data.AddMany(variables); return(TransformText(ec)); }
public string TransformText(HxlTemplateContext context) { StringWriter sw = new StringWriter(); Transform(sw, context); return(sw.ToString()); }
public void Transform(string outputFile, HxlTemplateContext context) { using (FileStream fs = new FileStream(outputFile, FileMode.Create)) { using (StreamWriter sw = new StreamWriter(fs)) { Transform(sw, context); } } }
public void PushTemplateContext(HxlTemplateContext templateContext) { if (templateContext == null) { throw new ArgumentNullException("templateContext"); } this._contexts.Push(templateContext); }
internal void Execute_(HxlTemplateContext context) { try { this.TemplateContext = context; SyncDataProperty(); Execute(); } finally { this.TemplateContext = null; } }
public HxlMasterInfo(IHxlPlaceholderContentProvider placeholderContent, HxlTemplateContext applyingTo, DomElement mergeAttributes, string layoutName) { _placeholderContent = placeholderContent; _applyingTo = applyingTo; _layoutElement = mergeAttributes; _layoutName = layoutName; }
public virtual void Transform(Stream outputStream, HxlTemplateContext context) { if (outputStream == null) { throw new ArgumentNullException("outputStream"); } using (StreamWriter sw = new StreamWriter(outputStream)) { Transform(sw, context); } }
internal static HxlTemplateContext WithData(HxlTemplate owner, IEnumerable <KeyValuePair <string, object> > variables) { var tc = new HxlTemplateContext(owner); if (variables != null) { foreach (var e in variables) { tc.Data.Add(e.Key, e.Value); } } return(tc); }
protected override void Render() { // Capture placeholder content var placeholderContent = HxlPlaceholderContentProvider.FromElement(Element); HxlMasterInfo masterInfo = new HxlMasterInfo(placeholderContent, null, this.Element, _layoutName); var output = this.Output; HxlTemplateContext context = this.TemplateContext; var master = LoadMaster(context.TemplateFactory, _ignoreErrors, _layoutName); var childContext = context.CreateChildContext(master); childContext.SetMasterInfo(masterInfo); master.Transform(output, childContext); }
internal void Render_(HxlTemplateContext templateContext, HxlWriter hxlWriter) { try { this.TemplateContext = templateContext; _outputBuffer = hxlWriter; if (Rendering != null) { Rendering(templateContext, this); } Render(); } finally { this.TemplateContext = null; _outputBuffer = InvalidTextOutput.Instance; } }
internal IHxlElementTemplate OnElementRendering_(HxlTemplateContext context) { try { this._templateContext = context; this._outputBuffer = CreateOutputBuffer(); if (Rendering != null) { Rendering(context, this); } // TODO This may benefit from being overridable behavior GetElementData(); return(OnElementRendering()); } finally { this._templateContext = null; this._outputBuffer = null; } }
public override void Transform(TextWriter outputWriter, HxlTemplateContext context) { if (outputWriter == null) { throw new ArgumentNullException("outputWriter"); } if (context == null) { context = new HxlTemplateContext(this); } PushTemplateContext(context); try { this.Output = outputWriter; EnsureInit(); ApplyMaster(); TransformTextCore(); } finally { this.Output = null; PopTemplateContext(); } }
public void Transform(Stream outputStream, IEnumerable <KeyValuePair <string, object> > variables) { Transform(outputStream, HxlTemplateContext.WithData(this, variables)); }
public void Transform(string outputFile, HxlTemplateContext context) { CreateInstance().Transform(outputFile, context); }
public void Transform(TextWriter outputWriter, HxlTemplateContext context) { CreateInstance().Transform(outputWriter, context); }
public string TransformText() { HxlTemplateContext ec = new HxlTemplateContext(this); return(TransformText(ec)); }
public virtual Task <string> TransformTextAsync(HxlTemplateContext context) { return(Task.Run(() => TransformText(context))); }
public virtual Task TransformAsync(TextWriter outputWriter, HxlTemplateContext context) { return(Task.Run(() => Transform(outputWriter, context))); }
public string TransformText(HxlTemplateContext context) { return(CreateInstance().TransformText(context)); }
public void Transform(TextWriter outputWriter, IEnumerable <KeyValuePair <string, object> > variables) { Transform(outputWriter, HxlTemplateContext.WithData(this, variables)); }
internal static IHxlElementTemplate ProcessAttributesForTemplate(DomElement element, HxlTemplateContext templateContext) { // TODO Cloning array is wasteful (performance) // TODO If attributes are added, they aren't considered // so if they are server attributes they don't get OnElementRendering_ (rare) IHxlElementTemplate template = null; // TODO Sort attributes by priority // TODO Capture any attribute text output (uncommon) foreach (var af in element.Attributes.OfType <HxlAttribute>().ToArray()) { if (af != null) { // TODO Probably need to push context template = af.OnElementRendering_(templateContext) ?? template; } } return(template); }
public override void Transform(TextWriter outputWriter, HxlTemplateContext context) { throw FutureFeatures.CompileAndEmit(); }
public void WriteTo(TextWriter writer, HxlTemplateContext templateContext) { WriteTo(writer, new HxlWriterSettings { TemplateContext = templateContext }); }
public abstract void Transform(TextWriter outputWriter, HxlTemplateContext context);
public void Transform(Stream outputStream, HxlTemplateContext context) { CreateInstance().Transform(outputStream, context); }