Ejemplo n.º 1
0
        private void Init()
        {
            _fnTbl     = new Dictionary<string, FunctionDefinition> (StringComparer.InvariantCultureIgnoreCase);
            _variables = new Variable();

            _variables["true"]  = true;
            _variables["false"] = false;
            _variables["null"]  = null;

            _Templates = new Templates();

            Logical.Register(this, _Templates);
        }
Ejemplo n.º 2
0
        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;
            }
        }
Ejemplo n.º 3
0
 public Variable(Variable parent)
 {
     this.parent = parent;
     this.values = new Dictionary<string, object> (StringComparer.InvariantCultureIgnoreCase);
 }