Exemple #1
0
 string ProcessTagFunction(TagFunction tagF)
 {
     return EvalTagFunction(tagF).ToString();
 }
        /// <summary>
        /// 读取Tag
        /// </summary>
        /// <returns></returns>
        Tag ReadTag()
        {
            Continue(Token.TokenKind.TagStart);
            Token tagID = Continue(Token.TokenKind.ID);
            Tag tag;
            if (currentToken.Kind == Token.TokenKind.Colon)
            {
                Continue(Token.TokenKind.Colon);
                Token token = Continue(Token.TokenKind.ID);
                tag = new TagFunction(tagID.Line, tagID.Col, tagID.Text, token.Text);
            }
            else
                tag = new Tag(tagID.Line, tagID.Col, tagID.Text);
            tag.Attributes = ReadAttributes();

            ////test
            //if (currentToken.Kind == Token.TokenKind.TextData)
            //{
            //    Token template = Continue(Token.TokenKind.TextData);
            //    tag.InnerElements.Add(new StringExpression(currentToken.Line, currentToken.Col, template.Text));
            //}

            return tag;
        }
Exemple #3
0
        /// <summary>
        /// 执行内置标签函数
        /// </summary>
        /// <param name="tagF"></param>
        /// <returns></returns>
        object EvalTagFunction(TagFunction tagF)
        {
            Dictionary<string, object> temp = new Dictionary<string, object>();

            foreach (TagAttribute tagA in tagF.Attributes)
            {
                temp.Add(tagA.Name, EvalExpression(tagA.Expression));
            }
            if (tagF.InnerElements.Count > 0)
            {
                Template t = Template.FromElements(tagF.InnerElements);
                temp.Add("template", t);
            }
            TagFunctionInvoker invoker = new TagFunctionInvoker();
            return invoker.Invoke(tagF.FunctionName, temp);
        }