Skip to content
This repository has been archived by the owner on Dec 19, 2018. It is now read-only.

Add ITagHelperComponent #1096

Merged
merged 6 commits into from
Mar 24, 2017
Merged

Add ITagHelperComponent #1096

merged 6 commits into from
Mar 24, 2017

Conversation

jbagga
Copy link
Contributor

@jbagga jbagga commented Mar 20, 2017

Copy link
Contributor

@NTaylorMullen NTaylorMullen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just looking for a Process helper method. Other comments are minor.

public interface ITagHelperComponent
{
/// <summary>
/// When a set of<see cref= "ITagHelperComponent" />s are executed, their <see cref="Init(TagHelperContext)"/>'s
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spacing


namespace Microsoft.AspNetCore.Razor.Runtime.TagHelpers
{
public class TagHelperComponent : ITagHelperComponent
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docs

public virtual void Init(TagHelperContext context)
{
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably makes sense to add a helper Process method here like we have on TagHelper

@@ -14,7 +14,7 @@ namespace Microsoft.AspNetCore.Razor.Runtime.TagHelpers
public class TagHelperRunner
{
/// <summary>
/// Calls the <see cref="ITagHelper.ProcessAsync"/> method on <see cref="ITagHelper"/>s.
/// Calls the <see cref="ITagHelperComponent.ProcessAsync"/> method on <see cref="ITagHelper"/>s.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should still say ITagHelper

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jbagga do we need to change this still?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It cannot resolve ITagHelper.ProcessAsync since the definition is now in ITagHelperComponent

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see. Then I think it's fine as-is.

/// Returns <c>true</c> to indicate if <see cref="ITagHelperComponent"/> applies to the given <see cref="TagHelperContext"/>.
/// </summary>
/// <param name="context">Contains information associated with the current HTML tag.</param>
public virtual bool AppliesTo(TagHelperContext context)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Who calls AppliesTo? If it's going to be on the convenience-base-class it needs to be called.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really good point. The bits here in Razor are mostly to facilitate a TagHelper looking type that isn't actually a TagHelper. @DamianEdwards did you envision the AppliesTo functionality living in Razor or letting ITagHelperComponent authors do their own IF statements?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Talked with @DamianEdwards offline. Lets remove this method and allow people who want to write TagHelperComponent's write their own if statements 😄. Note that this also removes the need to log "taghelper component applies to X"

namespace Microsoft.AspNetCore.Razor.TagHelpers
{
/// <summary>
/// Contract used to filter matching HTML elements.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The doc comment here is identical to the one for ITagHelper (minus the "marker" comment). How can we do a better job distinguishing the docs for these two different types?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@NTaylorMullen Should we explain the difference between ITagHelper and ITagHelperComponent in the doc comments?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't explain the difference between the two. I'd explain that ITagHelperComponent enables users to mutate the representation of an HTML element. ITagHelper on the other hand is still a contract to filter matching HTML elements.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I think each should just say what they are and what they're for.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@NTaylorMullen Why should I nuke the doc comment for ITagHelper then? #1096 (comment)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@NTaylorMullen Why should I nuke the doc comment for ITagHelper then? #1096 (comment)

It was an old comment prior to me noticing the doc comment similarities. Deleted the comment 😄

@jbagga jbagga force-pushed the jbagga/TagHelperComponentMvc5728 branch from 1b943a1 to 9167c16 Compare March 22, 2017 22:15
@jbagga
Copy link
Contributor Author

jbagga commented Mar 22, 2017

@NTaylorMullen @Eilon Updated. Please review the docs. I am not very happy with the base class docs

namespace Microsoft.AspNetCore.Razor.TagHelpers
{
/// <summary>
/// Contract used to enable the modification of an HTML element's representation.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Contract used to modify an HTML element.

public interface ITagHelperComponent
{
/// <summary>
/// When a set of <see cref= "ITagHelperComponent" />s are executed, their <see cref="Init(TagHelperContext)"/>'s
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spacing

/// </summary>
public abstract class TagHelper : ITagHelper
{
/// <inheritdoc />
/// <summary>
/// When a set of <see cref= "ITagHelper" />s are executed, their <see cref="Init(TagHelperContext)"/>'s
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spacing

@jbagga jbagga force-pushed the jbagga/TagHelperComponentMvc5728 branch from 9167c16 to a2fb67c Compare March 22, 2017 23:40
@jbagga
Copy link
Contributor Author

jbagga commented Mar 22, 2017

@NTaylorMullen @Eilon Updated

Copy link
Contributor

@NTaylorMullen NTaylorMullen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Can get this in on its own and then can react in your MVC PR.

@jbagga jbagga force-pushed the jbagga/TagHelperComponentMvc5728 branch from a6461fa to 3637a25 Compare March 23, 2017 22:52
@jbagga jbagga merged commit fe6517d into dev Mar 24, 2017
jbagga added a commit to aspnet/Mvc that referenced this pull request Mar 24, 2017
@jbagga jbagga deleted the jbagga/TagHelperComponentMvc5728 branch March 24, 2017 23:23
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants