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;
            }
        }
示例#3
0
 private void HandleFreeWithIgnoredUnkownTagsNestedBody(ITagAttributeSetter tagReflection)
 {
     _helper.PushIgnoreUnkownTag(true);
     var attribute = new TemplateAttribute(ParseNested(_helper, _locator));
     tagReflection["Body"] = attribute;
     _helper.PopIgnoreUnkownTag();
 }
示例#4
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;
     }
 }
 public void RenderShouldDelegateCallToHtmlHelperShouldUseAttributesAndProvideTagModel()
 {
     var attribute =
         new TemplateAttribute(new ParsedTemplate(null, new ExpressionPart(new ExpressionLib().Parse("name"))));
     var tag = Html.New<TestHtmlTag>(new List<IParameterValue>
                                         {
                                             new TestParameterValue {Name = "isChecked", TestValue = true},
                                             new ParameterValue {Name = "name", Attribute = attribute},
                                         }
         );
     Assert.That(tag.Method, Is.Not.Null);
     var model = new TagModel(new Hashtable());
     model.Model["name"] = "a";
     model.Page[Html.PAGE_MODEL_HTMLHELPER_INSTANCE] = GetHelper();
     string result = tag.Evaluate(model);
     Assert.That(result.Contains("name=\"a\""));
     Assert.That(result.Contains("checked=\"checked\""));
 }