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

Add AnchorTagHelper. #1334

Closed
wants to merge 1 commit into from
Closed

Conversation

NTaylorMullen
Copy link

@NTaylorMullen NTaylorMullen changed the title Add AnchorTagHelper. [Design] Add AnchorTagHelper. Oct 11, 2014
if (Action != null || Controller != null || Route != null)
{
// User specified an href AND a Action, Controller or Route; can't determine the href attribute.
throw new InvalidOperationException(
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we shouldn't throw here.
example - The a tag is populated by javascript based on the id tag.
so instead do nothing?

CC @DamianEdwards

Copy link
Contributor

Choose a reason for hiding this comment

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

+1 this is another case where, like "controller" and "route-value" in the <form/> helper, we should be consistent. I agree we shouldn't second-guess the users's intent when they force the tag helper to no-op.

Copy link
Author

Choose a reason for hiding this comment

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

Talked in person.

@NTaylorMullen
Copy link
Author

Addressed comments that didn't have a pending question.

@@ -117,6 +117,12 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="AnchorTagHelper_CannotDetermineHrefOneSpecified" xml:space="preserve">
<value>Cannot determine an href for {0}. {0}s with a specified href must not have a {1}, {2} or {3} attribute.</value>
Copy link
Contributor

Choose a reason for hiding this comment

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

I know it's just a design PR, but: recommend passing in href as a parameter to the string. And also recommend not pluralizing the {0}s in the second sentence, and instead saying A {0} with a specified...

@NTaylorMullen
Copy link
Author

Addressed comments.

@NTaylorMullen NTaylorMullen changed the title [Design] Add AnchorTagHelper. Add AnchorTagHelper. Oct 13, 2014
@NTaylorMullen
Copy link
Author

Added tests.

/// <summary>
/// The name of the action method.
/// </summary>
/// <remarks>Cannot be provided if <see cref="Route"/> is specified.</remarks>
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: reword these "cannot" <remarks/> to avoid passive voice: Must be <c>null</c> if <see cref="Route"/> is non-<c>null</c>.

Copy link
Contributor

Choose a reason for hiding this comment

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

(hmm, updated comment is slightly passive but at least is in terms of the properties here and not some random "specifier".)

@dougbu
Copy link
Contributor

dougbu commented Oct 13, 2014

⌚ and if I missed some form-related comments, assume they apply here as well

@NTaylorMullen
Copy link
Author

Addressed code review comments & tests.

public string Route { get; set; }

/// <inheritdoc />
/// <remarks>Does nothing if user provides an "href" attribute. Cannot specify an "href" attribute AND
Copy link
Contributor

Choose a reason for hiding this comment

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

don't yell

@NTaylorMullen
Copy link
Author

Addressed code review comments.

public string Protocol { get; set; }

/// <summary>
/// The host name for the URL.
Copy link
Contributor

Choose a reason for hiding this comment

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

teensy nit: leave off "for the URL" to be consistent w/ the other properties

@dougbu
Copy link
Contributor

dougbu commented Oct 15, 2014

⌚ for the restore some / throw on others follow-up

@NTaylorMullen
Copy link
Author

Addressed code review comments.

Fragment != null ||
routePrefixedAttributes.Any())
{
// User specified an href AND a Action, Controller or Route; can't determine the href attribute.
Copy link
Contributor

Choose a reason for hiding this comment

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

nits:

  • don't yell
  • remove list of attributes (it's incomplete): just "one of the bound attributes"

@dougbu
Copy link
Contributor

dougbu commented Oct 16, 2014

:shipit: after fixing Exception message arguments

- Added a TagHelper that targets the <a> tag and allows users to do the equivalent of Html.ActionLink or Html.RouteLink.
- Added tests to validate AnchorTagHelper functionality.

#1247
@NTaylorMullen NTaylorMullen deleted the TagHelpers_Anchor branch October 16, 2014 00:38
This pull request was closed.
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.

4 participants