private void HandleFreeWithIgnoredUnkownTagsNestedBody(ITagAttributeSetter tagReflection)
        {
            _helper.PushIgnoreUnkownTag(true);
            var attribute = new TemplateAttribute(ParseNested(_helper, _locator));

            tagReflection["Body"] = attribute;
            _helper.PopIgnoreUnkownTag();
        }
        private void AddAttributes(ITagAttributeSetter tagReflection, ITag tag)
        {
            while (!_helper.IsAhead(CLOSING_TOKENS))
            {
//                _helper.Read(TokenType.Seperator);
                _helper.Next();
                ReadWhiteSpace(_helper);
                if (_helper.IsAhead(CLOSING_TOKENS))
                {
                    return;
                }
                var keyToken = _helper.Read(TokenType.Regular);
                var key      = tagReflection.SupportNaturalLanguage?LanguageHelper.CamelCaseAttribute(keyToken.Contents): keyToken.Contents;
                _helper.Read(TagLibConstants.FIELD_ASSIGNMENT);
                var value    = _helper.Read(TokenType.Literal).Contents;
                var existing = tagReflection[key];
                if (!existing?.AllowOverWrite ?? false)
                {
                    throw TagException.PropertyAlReadySet(key).Decorate(keyToken.Context);
                }
                if (string.IsNullOrEmpty(value))
                {
                    tagReflection[key] = new ConstantAttribute("", tag)
                    {
                        AttributeName = key, Context = keyToken.Context
                    };
                    continue;
                }
                if (!value.Contains("${"))
                {
                    tagReflection[key] = new ConstantAttribute(value, tag)
                    {
                        AttributeName = key, Context = keyToken.Context, ResourceLocator = _locator
                    };
                    continue;
                }
                var offSet = _helper.Current.Context;
                var attr   = new TemplateAttribute(new InternalFormatter(new TagLibParserFactoryAdapter(this), _expressionLib, value, false, _locator, offSet).Parse())
                {
                    AttributeName = key
                };
                tagReflection[key] = attr;
            }
        }
 private void HandleBody(ITag tag, ITagAttributeSetter tagReflection)
 {
     if (tag.TagBodyMode == TagBodyMode.Free)
     {
         HandleFreeNestedBody(tagReflection);
         ITag closingTag = Parse();
         GuardClosingOfTag(closingTag, tag);
     }
     else if (tag.TagBodyMode == TagBodyMode.NestedTags)
     {
         HandleNestedTagBody((ITagWithNestedTags)tag);
     }
     else if (tag.TagBodyMode == TagBodyMode.FreeIgnoreUnkown)
     {
         HandleFreeWithIgnoredUnkownTagsNestedBody(tagReflection);
         ITag closingTag = Parse();
         GuardClosingOfTag(closingTag, tag);
     }
     else
     {
         ITag closingTag = Parse();
         GuardClosingOfTag(closingTag, tag);
     }
 }
Пример #4
0
 private void HandleFreeWithIgnoredUnkownTagsNestedBody(ITagAttributeSetter tagReflection)
 {
     _helper.PushIgnoreUnkownTag(true);
     var attribute = new TemplateAttribute(ParseNested(_helper, _locator));
     tagReflection["Body"] = attribute;
     _helper.PopIgnoreUnkownTag();
 }
Пример #5
0
 private void HandleBody(ITag tag, ITagAttributeSetter tagReflection)
 {
     if (tag.TagBodyMode == TagBodyMode.Free)
     {
         HandleFreeNestedBody(tagReflection);
         ITag closingTag = Parse();
         GuardClosingOfTag(closingTag, tag);
     }
     else if (tag.TagBodyMode == TagBodyMode.NestedTags)
     {
         HandleNestedTagBody((ITagWithNestedTags) tag);
     }
     else if (tag.TagBodyMode == TagBodyMode.FreeIgnoreUnkown)
     {
         HandleFreeWithIgnoredUnkownTagsNestedBody(tagReflection);
         ITag closingTag = Parse();
         GuardClosingOfTag(closingTag, tag);
     }
     else
     {
         ITag closingTag = Parse();
         GuardClosingOfTag(closingTag, tag);
     }
 }
Пример #6
0
 private void AddAttributes(ITagAttributeSetter tagReflection, ITag tag)
 {
     while (!_helper.IsAhead(TagLibConstants.CLOSE_TAG, TagLibConstants.CLOSE_SLASH))
     {
         _helper.Read(TokenType.Seperator);
         ReadWhiteSpace(_helper);
         if (_helper.IsAhead(TagLibConstants.CLOSE_SLASH, TagLibConstants.CLOSE_TAG))
         {
             return;
         }
         var keyToken = _helper.Read(TokenType.Regular);
         var key = tagReflection.SupportNaturalLanguage?LanguageHelper.CamelCaseAttribute(keyToken.Contents): keyToken.Contents;
         _helper.Read(TagLibConstants.FIELD_ASSIGNMENT);
         var value = _helper.Read(TokenType.Literal).Contents;
         if (tagReflection[key] != null && !tagReflection[key].AllowOverWrite)
         {
             throw TagException.PropertyAlReadySet(key).Decorate(keyToken.Context);
         }
         if (string.IsNullOrEmpty(value))
         {
             tagReflection[key] =new ConstantAttribute("", tag) {AttributeName = key,Context = keyToken.Context };
             continue;
         }
         var offSet = _helper.Current.Context;
         var attr=new TemplateAttribute(new InternalFormatter(new TagLibParserFactoryAdapter(this), _expressionLib, value, false, _locator, offSet).Parse()) { AttributeName = key };
         tagReflection[key] = attr;
     }
 }
Пример #7
0
 public FreeFieldsAttributeSetter(IDictionary <string, ITagAttribute> freeAttribs, ITagAttributeSetter parent)
 {
     _freeAttribs = freeAttribs;
     _parent      = parent;
 }