public StringValue Render( RenderingVisitor renderingVisitor, MacroBlockTag macroBlocktag, ITemplateContext templateContext, IList<Option<IExpressionConstant>> args) { var macroScope = new SymbolTable(); var i = 0; foreach (var varName in macroBlocktag.Args.Take(args.Count)) { macroScope.DefineLocalVariable(varName, args[i].HasValue? args[i].Value : null); i++; } templateContext.SymbolTableStack.Push(macroScope); //String result = ""; //var subRenderer = new RenderingVisitor(evaluator, templateContext, str => result += str); //evaluator.StartVisiting(subRenderer, macroBlocktag.LiquidBlock); String hiddenText = ""; renderingVisitor.PushTextAccumulator(str => hiddenText += str); renderingVisitor.StartWalking(macroBlocktag.LiquidBlock); renderingVisitor.PopTextAccumulator(); templateContext.SymbolTableStack.Pop(); // foreach (var error in subRenderer.Errors) // { // errorAccumulator.Add(error); // } return new StringValue(hiddenText); }
public void Visit(MacroBlockTag macroBlockTag) { _result += macroBlockTag.ToString(); }
public void Visit(MacroBlockTag macroBlockTag) { _templateContext.SymbolTableStack.DefineMacro(macroBlockTag.Name, macroBlockTag); }
public void DefineMacro(string name, MacroBlockTag macro) { _symbolTables.Last().DefineMacro(name, macro); }
private string RenderMacro(MacroBlockTag macroBlockTag, IEnumerable<Option<IExpressionConstant>> args) { var macroRenderer = new MacroRenderer(); //IList<LiquidError> macroErrors = new List<LiquidError>(); //var macro = ValueCaster.RenderAsString((IExpressionConstant) macroRenderer.Render(macroBlockTag, _templateContext, args.ToList(), macroErrors)); var macro = ValueCaster.RenderAsString((IExpressionConstant)macroRenderer.Render(this, macroBlockTag, _templateContext, args.ToList())); //foreach (var error in macroErrors) //{ //Errors.Add(error); //} return macro; }