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

Add extensions for TagHelperOutput to copy from TagBuilder. #1360

Merged
merged 0 commits into from
Oct 16, 2014

Conversation

NTaylorMullen
Copy link

public static IEnumerable<KeyValuePair<string, string>> PullPrefixedAttributes(
this TagHelperOutput tagHelperOutput, string prefix)
{
// TODO: We will not need this method once https://github.com/aspnet/Razor/issues/89 is completed.
Copy link
Contributor

Choose a reason for hiding this comment

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

  • why does this name remain unchanged?
  • FYI I kind-of liked @yishaigalatzer's suggestion to split this in two -- say FindPrefixedAttributes() and RemovePrefixedAttributes() (or perhaps RemoveRange() if Linq doesn't provide that as an IEnumerable extension)

@dougbu
Copy link
Contributor

dougbu commented Oct 15, 2014

  • improve commit description -- does more than test something out

@NTaylorMullen
Copy link
Author

Addressed code review comments.

TagHelperContext context)
{
// We look for the original attribute so we can restore the exact attribute name the user typed.
var entry = context.AllAttributes.Single(attribute =>
Copy link
Contributor

Choose a reason for hiding this comment

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

If you don't care about throwing an exception if there's more than one item (and you shouldn't be relying on Singles exception message anyway), use First() instead.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, what's the type of AllAttributes?

Copy link
Author

Choose a reason for hiding this comment

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

AllAttributes = Dictionary<string, object>

@pranavkm
Copy link
Contributor

:shipit: once @dougbu's happy

@NTaylorMullen
Copy link
Author

Addressed pranav's comments.

public static class TagHelperOutputExtensions
{
/// <summary>
/// Copies a user provided attribute from <paramref name="context"/>'s
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: "user-provided"

@dougbu
Copy link
Contributor

dougbu commented Oct 15, 2014

⌚ let's discuss CopyHtmlAttribute() merging @class values offline

@NTaylorMullen
Copy link
Author

@dougbu After addressing nits am I got to ship since we discussed the one @class piece offline?

@NTaylorMullen
Copy link
Author

Addressed code review comments.

@dougbu
Copy link
Contributor

dougbu commented Oct 15, 2014

:shipit:

@NTaylorMullen NTaylorMullen merged commit b7a38c3 into TagHelpersFeature Oct 16, 2014
@NTaylorMullen NTaylorMullen force-pushed the TagHelpers_CopyHelpers branch from e127da2 to b7a38c3 Compare October 16, 2014 00:34
@NTaylorMullen NTaylorMullen deleted the TagHelpers_CopyHelpers branch October 16, 2014 00:38
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.

3 participants