public LiquidString Render( RenderingVisitor renderingVisitor, MacroBlockTag macroBlocktag, ITemplateContext templateContext, IList <Option <ILiquidValue> > args) { var macroScope = new SymbolTable(); var i = 0; foreach (var varName in macroBlocktag.Args.Take(args.Count)) { macroScope.DefineLocalVariable(varName, args[i]); i++; } templateContext.SymbolTableStack.Push(macroScope); String hiddenText = ""; renderingVisitor.PushTextAccumulator(str => hiddenText += str); renderingVisitor.StartWalking(macroBlocktag.LiquidBlock); renderingVisitor.PopTextAccumulator(); templateContext.SymbolTableStack.Pop(); return(LiquidString.Create(hiddenText)); }
private string RenderMacro(MacroBlockTag macroBlockTag, IEnumerable <Option <ILiquidValue> > args) { var macroRenderer = new MacroRenderer(); var expressionConstant = (ILiquidValue)macroRenderer.Render(this, macroBlockTag, _templateContext, args.ToList()); return(ValueCaster.RenderAsString(expressionConstant)); }
public void DefineMacro(String key, MacroBlockTag macro) { if (_macroRegistry.ContainsKey(key)) { _macroRegistry[key] = macro; } else { _macroRegistry.Add(key, macro); } }
public void Visit(MacroBlockTag macroBlockTag) { _result += macroBlockTag.ToString(); }
public void DefineMacro(string name, MacroBlockTag macro) { _symbolTables.Last().DefineMacro(name, macro); }
public void Visit(MacroBlockTag macroBlockTag) { _templateContext.SymbolTableStack.DefineMacro(macroBlockTag.Name, macroBlockTag); }