diff --git a/src/Microsoft.AspNetCore.Razor.Runtime/Runtime/TagHelpers/TagHelperRunner.cs b/src/Microsoft.AspNetCore.Razor.Runtime/Runtime/TagHelpers/TagHelperRunner.cs index d4c18d2eb..89a8b0e2a 100644 --- a/src/Microsoft.AspNetCore.Razor.Runtime/Runtime/TagHelpers/TagHelperRunner.cs +++ b/src/Microsoft.AspNetCore.Razor.Runtime/Runtime/TagHelpers/TagHelperRunner.cs @@ -14,7 +14,7 @@ namespace Microsoft.AspNetCore.Razor.Runtime.TagHelpers public class TagHelperRunner { /// - /// Calls the method on s. + /// Calls the method on s. /// /// Contains information associated with running s. /// diff --git a/src/Microsoft.AspNetCore.Razor.Runtime/TagHelpers/ITagHelper.cs b/src/Microsoft.AspNetCore.Razor.Runtime/TagHelpers/ITagHelper.cs index f65c7fcb2..ec86a32a1 100644 --- a/src/Microsoft.AspNetCore.Razor.Runtime/TagHelpers/ITagHelper.cs +++ b/src/Microsoft.AspNetCore.Razor.Runtime/TagHelpers/ITagHelper.cs @@ -1,41 +1,13 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using System.Threading.Tasks; - namespace Microsoft.AspNetCore.Razor.TagHelpers { /// /// Contract used to filter matching HTML elements. + /// Marker interface for s. /// - public interface ITagHelper + public interface ITagHelper : ITagHelperComponent { - /// - /// When a set of s are executed, their's - /// are first invoked in the specified ; then their - /// 's are invoked in the specified - /// . Lower values are executed first. - /// - int Order { get; } - - /// - /// Initializes the with the given . Additions to - /// should be done within this method to ensure they're added prior to - /// executing the children. - /// - /// Contains information associated with the current HTML tag. - /// When more than one runs on the same element, - /// may be invoked prior to . - /// - void Init(TagHelperContext context); - - /// - /// Asynchronously executes the with the given and - /// . - /// - /// Contains information associated with the current HTML tag. - /// A stateful HTML element used to generate an HTML tag. - /// A that on completion updates the . - Task ProcessAsync(TagHelperContext context, TagHelperOutput output); } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Razor.Runtime/TagHelpers/ITagHelperComponent.cs b/src/Microsoft.AspNetCore.Razor.Runtime/TagHelpers/ITagHelperComponent.cs new file mode 100644 index 000000000..3b2059be5 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Runtime/TagHelpers/ITagHelperComponent.cs @@ -0,0 +1,41 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Threading.Tasks; + +namespace Microsoft.AspNetCore.Razor.TagHelpers +{ + /// + /// Contract used to modify an HTML element. + /// + public interface ITagHelperComponent + { + /// + /// When a set of s are executed, their 's + /// are first invoked in the specified ; then their + /// 's are invoked in the specified + /// . Lower values are executed first. + /// + int Order { get; } + + /// + /// Initializes the with the given . Additions to + /// should be done within this method to ensure they're added prior to + /// executing the children. + /// + /// Contains information associated with the current HTML tag. + /// When more than one runs on the same element, + /// may be invoked prior to . + /// + void Init(TagHelperContext context); + + /// + /// Asynchronously executes the with the given and + /// . + /// + /// Contains information associated with the current HTML tag. + /// A stateful HTML element used to generate an HTML tag. + /// A that on completion updates the . + Task ProcessAsync(TagHelperContext context, TagHelperOutput output); + } +} diff --git a/src/Microsoft.AspNetCore.Razor.Runtime/TagHelpers/TagHelper.cs b/src/Microsoft.AspNetCore.Razor.Runtime/TagHelpers/TagHelper.cs index 7c1a9b1d1..3a6084c4e 100644 --- a/src/Microsoft.AspNetCore.Razor.Runtime/TagHelpers/TagHelper.cs +++ b/src/Microsoft.AspNetCore.Razor.Runtime/TagHelpers/TagHelper.cs @@ -7,15 +7,28 @@ namespace Microsoft.AspNetCore.Razor.TagHelpers { /// - /// Class used to filter matching HTML elements. + /// An abstract base class for . /// public abstract class TagHelper : ITagHelper { - /// + /// + /// When a set of s are executed, their 's + /// are first invoked in the specified ; then their + /// 's are invoked in the specified + /// . Lower values are executed first. + /// /// Default order is 0. public virtual int Order { get; } = 0; - /// + /// + /// Initializes the with the given . Additions to + /// should be done within this method to ensure they're added prior to + /// executing the children. + /// + /// Contains information associated with the current HTML tag. + /// When more than one runs on the same element, + /// may be invoked prior to . + /// public virtual void Init(TagHelperContext context) { } diff --git a/src/Microsoft.AspNetCore.Razor.Runtime/TagHelpers/TagHelperComponent.cs b/src/Microsoft.AspNetCore.Razor.Runtime/TagHelpers/TagHelperComponent.cs new file mode 100644 index 000000000..ba6987873 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Runtime/TagHelpers/TagHelperComponent.cs @@ -0,0 +1,40 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Threading.Tasks; +using Microsoft.Extensions.Internal; + +namespace Microsoft.AspNetCore.Razor.TagHelpers +{ + /// + /// An abstract base class for . + /// + public abstract class TagHelperComponent : ITagHelperComponent + { + /// + /// Default order is 0. + public virtual int Order => 0; + + /// + public virtual void Init(TagHelperContext context) + { + } + + /// + /// Synchronously executes the with the given and + /// . + /// + /// Contains information associated with the current HTML tag. + /// A stateful HTML element used to generate an HTML tag. + public virtual void Process(TagHelperContext context, TagHelperOutput output) + { + } + + /// + public virtual Task ProcessAsync(TagHelperContext context, TagHelperOutput output) + { + Process(context, output); + return TaskCache.CompletedTask; + } + } +}