-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Add extensions for TagHelperOutput to copy from TagBuilder. #1360
Conversation
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. |
There was a problem hiding this comment.
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()
andRemovePrefixedAttributes()
(or perhapsRemoveRange()
if Linq doesn't provide that as anIEnumerable
extension)
|
6a61a8f
to
4208c8f
Compare
199a8e2
to
d3af121
Compare
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 => |
There was a problem hiding this comment.
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 Single
s exception message anyway), use First()
instead.
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AllAttributes
= Dictionary<string, object>
|
Addressed pranav's comments. |
public static class TagHelperOutputExtensions | ||
{ | ||
/// <summary> | ||
/// Copies a user provided attribute from <paramref name="context"/>'s |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: "user-provided"
⌚ let's discuss |
@dougbu After addressing nits am I got to ship since we discussed the one |
Addressed code review comments. |
|
e127da2
to
b7a38c3
Compare
Tag Helpers: Add TagHelperOutput extension methods to copy from TagBuilder #1319