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

React to aspnet/Razor#221: Modify TagHelpers to utilize new ContentMode design. #1795

Merged
merged 2 commits into from
Jan 17, 2015

Conversation

NTaylorMullen
Copy link

Modify TagHelpers to use new content mode design.

Modify TagHelper tests to abide by new content mode design.

@NTaylorMullen
Copy link
Author

/cc @pranavkm

@NTaylorMullen NTaylorMullen force-pushed the razor.thcontentmode.221 branch from 3b2df62 to 6735c30 Compare January 14, 2015 20:37
@@ -13,7 +13,7 @@
<form asp-anti-forgery="false" asp-action="Create">
<div class="form-horizontal">
@* validation summary tag helper will target just <div/> elements and append the list of errors *@
@* - i.e. this helper, like <select/> helper, has ContentBehavior.Append *@
@* - i.e. this helper, like <select/> helper appends content via *@
Copy link
Contributor

Choose a reason for hiding this comment

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

via what?

@dougbu
Copy link
Contributor

dougbu commented Jan 14, 2015

@NTaylorMullen
Copy link
Author

Updated.

{
output.Content = tagBuilder.InnerHtml;
output.Content = childContent;
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: this is hard on the eyes due to repeated conditions. suggest instead

  if (string.IsNullOrEmpty(output.Content))
  {
    if (string.IsNullOrWhiteSpace(childContent))
    {
      // Provide default label text since there was nothing useful in the Razor source.
      output.Content = tagBuilder.InnerHtml;
    }
    else
    {
      output.Content = childContent;
    }
  }

@dougbu
Copy link
Contributor

dougbu commented Jan 16, 2015

⌚ for reverting tagHelperContext -> context churn. (that'll make it easier to see real changes.) otherwise looks very close.

@NTaylorMullen
Copy link
Author

Updated.

// We check for whitespace to detect scenarios such as:
// <label for="Name">
// </label>
if (string.IsNullOrWhiteSpace(output.Content))
if (string.IsNullOrEmpty(output.Content))
Copy link
Contributor

Choose a reason for hiding this comment

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

late thought: should this check output.ContentSet instead?

Copy link
Author

Choose a reason for hiding this comment

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

Definitely up for discussion. However, i'm leaning towards leaving it as is purely for the ability for TagHelpers to reset the output.Content if they please (reset = setting to string.Empty or null). If you're only ever checking ContentSet then once it's set there's no going back.

Copy link
Contributor

Choose a reason for hiding this comment

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

let's rope in @DamianEdwards tomorrow. these tag helpers generally do not override what previous ones in the pipeline have done. diverging from that here.

Copy link
Author

Choose a reason for hiding this comment

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

done

@dougbu
Copy link
Contributor

dougbu commented Jan 16, 2015

⌚ for just a few open questions

@NTaylorMullen
Copy link
Author

Updated.

@NTaylorMullen
Copy link
Author

Rebased, verified test pass and updated.

[InlineData("Content of validation message", "Some Content", "Some Content")]
[InlineData("\r\n \r\n", "\r\n Something Else \r\n", "\r\n Something Else \r\n")]
[InlineData("\r\n \r\n", "Some Content", "Some Content")]
public async Task ProcessAsync_DoesntOverrideOutputContent(
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 abbreviate: DoesNot

@dougbu
Copy link
Contributor

dougbu commented Jan 16, 2015

:shipit: with one small fix and a rebase (since you signed off on ValidationSummaryTagHelper changes and it's likely 15 other commits happened since you last updated the PR)

N. Taylor Mullen added 2 commits January 16, 2015 15:50
- React to aspnet/Razor#221
- Modified existing TagHelpers to no longer rely on ContentBehavior and to instead utilize GetChildContentAsync, PreContent, Content and PostContent.
- React to aspnet/Razor#221
- Modified existing TagHelper tests to no longer rely on ContentBehavior.
- Updated signatures of TagHelperExecutionContext and TagHelperContext pieces.
@NTaylorMullen NTaylorMullen force-pushed the razor.thcontentmode.221 branch from da6387f to eb1eca9 Compare January 17, 2015 00:04
@NTaylorMullen NTaylorMullen merged commit eb1eca9 into dev Jan 17, 2015
@NTaylorMullen NTaylorMullen deleted the razor.thcontentmode.221 branch January 17, 2015 00:07
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.

2 participants