/// <summary> /// Instantiates a new instance of the <see cref="TagHelperBlockBuilder"/> class /// with the provided values. /// </summary> /// <param name="tagName">An HTML tag name.</param> /// <param name="tagMode">HTML syntax of the element in the Razor source.</param> /// <param name="start">Starting location of the <see cref="TagHelperBlock"/>.</param> /// <param name="attributes">Attributes of the <see cref="TagHelperBlock"/>.</param> /// <param name="descriptors">The <see cref="TagHelperDescriptor"/>s associated with the current HTML /// tag.</param> public TagHelperBlockBuilder( string tagName, TagMode tagMode, SourceLocation start, IList <TagHelperAttributeNode> attributes, IEnumerable <TagHelperDescriptor> descriptors) { TagName = tagName; TagMode = tagMode; Start = start; Descriptors = descriptors; Attributes = new List <TagHelperAttributeNode>(attributes); Type = BlockType.Tag; ChunkGenerator = new TagHelperChunkGenerator(descriptors); }
/// <summary> /// Instantiates a new instance of the <see cref="TagHelperBlockBuilder"/> class /// with the provided <paramref name="tagName"/> and derives its <see cref="Attributes"/> /// and <see cref="BlockBuilder.Type"/> from the <paramref name="startTag"/>. /// </summary> /// <param name="tagName">An HTML tag name.</param> /// <param name="selfClosing"> /// <see cref="bool"/> indicating whether or not the tag in the Razor source was self-closing. /// </param> /// <param name="start">Starting location of the <see cref="TagHelperBlock"/>.</param> /// <param name="attributes">Attributes of the <see cref="TagHelperBlock"/>.</param> /// <param name="descriptors">The <see cref="TagHelperDescriptor"/>s associated with the current HTML /// tag.</param> public TagHelperBlockBuilder( string tagName, bool selfClosing, SourceLocation start, IList <KeyValuePair <string, SyntaxTreeNode> > attributes, IEnumerable <TagHelperDescriptor> descriptors) { TagName = tagName; SelfClosing = selfClosing; Start = start; Descriptors = descriptors; Attributes = new List <KeyValuePair <string, SyntaxTreeNode> >(attributes); Type = BlockType.Tag; ChunkGenerator = new TagHelperChunkGenerator(descriptors); }
/// <summary> /// Instantiates a new instance of the <see cref="TagHelperBlockBuilder"/> class /// with the provided values. /// </summary> /// <param name="tagName">An HTML tag name.</param> /// <param name="tagMode">HTML syntax of the element in the Razor source.</param> /// <param name="start">Starting location of the <see cref="TagHelperBlock"/>.</param> /// <param name="attributes">Attributes of the <see cref="TagHelperBlock"/>.</param> /// <param name="descriptors">The <see cref="TagHelperDescriptor"/>s associated with the current HTML /// tag.</param> public TagHelperBlockBuilder( string tagName, TagMode tagMode, SourceLocation start, IList<TagHelperAttributeNode> attributes, IEnumerable<TagHelperDescriptor> descriptors) { TagName = tagName; TagMode = tagMode; Start = start; Descriptors = descriptors; Attributes = new List<TagHelperAttributeNode>(attributes); Type = BlockType.Tag; ChunkGenerator = new TagHelperChunkGenerator(descriptors); }
// Internal for testing internal TagHelperBlockBuilder( string tagName, TagMode tagMode, IList <TagHelperAttributeNode> attributes, IEnumerable <SyntaxTreeNode> children) { TagName = tagName; TagMode = tagMode; Attributes = attributes; Type = BlockType.Tag; ChunkGenerator = new TagHelperChunkGenerator(tagHelperDescriptors: null); // Children is IList, no AddRange foreach (var child in children) { Children.Add(child); } }
// Internal for testing internal TagHelperBlockBuilder( string tagName, bool selfClosing, IList <KeyValuePair <string, SyntaxTreeNode> > attributes, IEnumerable <SyntaxTreeNode> children) { TagName = tagName; SelfClosing = selfClosing; Attributes = attributes; Type = BlockType.Tag; ChunkGenerator = new TagHelperChunkGenerator(tagHelperDescriptors: null); // Children is IList, no AddRange foreach (var child in children) { Children.Add(child); } }
// Internal for testing internal TagHelperBlockBuilder( string tagName, TagMode tagMode, IList<TagHelperAttributeNode> attributes, IEnumerable<SyntaxTreeNode> children) { TagName = tagName; TagMode = tagMode; Attributes = attributes; Type = BlockType.Tag; ChunkGenerator = new TagHelperChunkGenerator(tagHelperDescriptors: null); // Children is IList, no AddRange foreach (var child in children) { Children.Add(child); } }
public override void VisitTagHelperBlock(TagHelperChunkGenerator chunkGenerator, Block block) { var tagHelperBlock = block as TagHelperBlock; if (tagHelperBlock == null) { return; } var tagName = tagHelperBlock.TagName; if (_tagHelperPrefix != null) { tagName = tagName.Substring(_tagHelperPrefix.Length); } var tagHelperNode = new TagHelperIntermediateNode() { TagName = tagName, TagMode = tagHelperBlock.TagMode, Source = BuildSourceSpanFromNode(block) }; foreach (var tagHelper in tagHelperBlock.Binding.Descriptors) { tagHelperNode.TagHelpers.Add(tagHelper); } _builder.Push(tagHelperNode); _builder.Push(new TagHelperBodyIntermediateNode()); VisitDefault(block); _builder.Pop(); // Pop InitializeTagHelperStructureIntermediateNode AddTagHelperAttributes(tagHelperBlock.Attributes, tagHelperBlock.Binding); _builder.Pop(); // Pop TagHelperIntermediateNode }
public virtual void VisitTagHelperBlock(TagHelperChunkGenerator chunkGenerator, Block block) { VisitDefault(block); }