private void InitTmpls() { this.tmpls = new Dictionary <string, Tmpl> (StringComparer.InvariantCultureIgnoreCase); foreach (Element elem in elements) { if (elem is Tag) { Tag tag = (Tag)elem; if (string.Compare(tag.Name, "define", true) == 0) { Expression ename = tag.AttributeValue("name"); string tname; if (ename is StringLiteral) { tname = ((StringLiteral)ename).Content; } else { tname = "?"; } Tmpl tmpl = new Tmpl(tname, tag.InnerElements, this); tmpls[tname] = tmpl; } } } }
public Tmpl(string name, List <Element> elements, Tmpl parent) { this.name = name; this.elements = elements; this.parent = parent; InitTmpls(); }
public Tmpl(string name, List <Element> elements) { this.name = name; this.elements = elements; this.parent = null; InitTmpls(); }
public Tmpl(string name, List<Token> elements, Tmpl parent) { this.name = name; this.elements = elements; this.parent = parent; InitTmpls(); }
public Tmpl(string name, List<Token> elements) { this.name = name; this.elements = elements; this.parent = null; InitTmpls(); }
public TmplManager(Tmpl tmpl) { _mainTmpl = tmpl; _currentTmpl = tmpl; _silentErrors = false; _scriptMode = false; Init(); }
private void ProcessTmpl(string name, Tag tag) { if (customTags != null && customTags.ContainsKey(name)) { ExecuteCustomTag(tag); return; } Tmpl useTmpl = _currentTmpl.FindTmpl(name); if (useTmpl == null) { string msg = string.Format("Tmpl '{0}' not found", name); throw new TmplException(msg, tag.Line, tag.Col); } TextWriter saveWriter = writer; writer = new StringWriter(); string content = string.Empty; try { ProcessElements(tag.InnerElements); content = writer.ToString(); } finally { writer = saveWriter; } Tmpl saveTmpl = _currentTmpl; _variables = new Variable(_variables); _variables["innerText"] = content; try { foreach (DotAttribute attrib in tag.Attributes) { object val = EvalExpression(attrib.Expression); _variables[attrib.Name] = val; } _currentTmpl = useTmpl; ProcessElements(_currentTmpl.Elements); } finally { _variables = _variables.Parent; _currentTmpl = saveTmpl; } }
public void Process(TextWriter writer) { this.writer = writer; this._currentTmpl = _mainTmpl; if (_handler != null) { SetValue("this", _handler); _handler.BeforeProcess(this); } ProcessElements(_mainTmpl.Elements); if (_handler != null) { _handler.AfterProcess(this); } }
public void AddTmpl(Tmpl tmpl) { _mainTmpl.Tmpls.Add(tmpl.Name, tmpl); }
private void ProcessTmpl(string name, Tag tag) { if (customTags != null && customTags.ContainsKey(name)) { ExecuteCustomTag(tag); return; } Tmpl useTmpl = _currentTmpl.FindTmpl(name); if (useTmpl == null) { string msg = string.Format("Tmpl '{0}' not found", name); throw new TmplException(msg, tag.Line, tag.Col); } TextWriter saveWriter = writer; writer = new StringWriter(); string content = string.Empty; try { ProcessElements(tag.InnerTokens); content = writer.ToString(); } finally { writer = saveWriter; } Tmpl saveTmpl = _currentTmpl; _variables = new Variable(_variables); _variables["innerText"] = content; try { foreach (DotAttribute attrib in tag.Attributes) { object val = EvalExpression(attrib.Expression); _variables[attrib.Name] = val; } _currentTmpl = useTmpl; ProcessElements(_currentTmpl.Elements); } finally { _variables = _variables.Parent; _currentTmpl = saveTmpl; } }
public static TmplManager Parser(string tmpl) { Tmpl iTmpl = Tmpl.Parser("", tmpl); return(new TmplManager(iTmpl)); }
private void InitTmpls() { this.tmpls = new Dictionary<string, Tmpl> (StringComparer.InvariantCultureIgnoreCase); foreach (Token elem in elements) { if (elem is Tag) { Tag tag = (Tag) elem; if (string.Compare(tag.Name, "define", true) == 0) { Expression ename = tag.AttributeValue("name"); string tname; if (ename is StringLiteral) { tname = ((StringLiteral) ename).Content; } else { tname = "?"; } Tmpl tmpl = new Tmpl(tname, tag.InnerTokens, this); tmpls[tname] = tmpl; } } } }