Rename `AppendEncoded()` to `AppendHtml()` and `SetContentEncoded()` to `SetHtmlContent()`
- aspnet/Mvc#3225, 2 of 3 - also correct parameter names
This commit is contained in:
parent
6a7082d89e
commit
117bbe7f65
|
|
@ -122,15 +122,16 @@ namespace Microsoft.AspNet.Razor.TagHelpers
|
|||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override TagHelperContent Append(string value)
|
||||
public override TagHelperContent Append(string unencoded)
|
||||
{
|
||||
Buffer.Append(value);
|
||||
Buffer.Append(unencoded);
|
||||
return this;
|
||||
}
|
||||
|
||||
public override TagHelperContent AppendEncoded(string value)
|
||||
/// <inheritdoc />
|
||||
public override TagHelperContent AppendHtml(string encoded)
|
||||
{
|
||||
Buffer.AppendEncoded(value);
|
||||
Buffer.AppendHtml(encoded);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -61,18 +61,18 @@ namespace Microsoft.AspNet.Razor.TagHelpers
|
|||
/// as-provided and no further encoding will be performed.
|
||||
/// </param>
|
||||
/// <returns>A reference to this instance after the set operation has completed.</returns>
|
||||
public TagHelperContent SetContentEncoded(string encoded)
|
||||
public TagHelperContent SetHtmlContent(string encoded)
|
||||
{
|
||||
HtmlContentBuilderExtensions.SetContentEncoded(this, encoded);
|
||||
HtmlContentBuilderExtensions.SetHtmlContent(this, encoded);
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Appends <paramref name="value"/> to the existing content.
|
||||
/// Appends <paramref name="unencoded"/> to the existing content.
|
||||
/// </summary>
|
||||
/// <param name="value">The <see cref="string"/> to be appended.</param>
|
||||
/// <param name="unencoded">The <see cref="string"/> to be appended.</param>
|
||||
/// <returns>A reference to this instance after the append operation has completed.</returns>
|
||||
public abstract TagHelperContent Append(string value);
|
||||
public abstract TagHelperContent Append(string unencoded);
|
||||
|
||||
/// <summary>
|
||||
/// Appends <paramref name="htmlContent"/> to the existing content.
|
||||
|
|
@ -82,12 +82,12 @@ namespace Microsoft.AspNet.Razor.TagHelpers
|
|||
public abstract TagHelperContent Append(IHtmlContent htmlContent);
|
||||
|
||||
/// <summary>
|
||||
/// Appends <paramref name="value"/> to the existing content. <paramref name="value"/> is assumed
|
||||
/// Appends <paramref name="encoded"/> to the existing content. <paramref name="encoded"/> is assumed
|
||||
/// to be an HTML encoded <see cref="string"/> and no further encoding will be performed.
|
||||
/// </summary>
|
||||
/// <param name="value">The <see cref="string"/> to be appended.</param>
|
||||
/// <param name="encoded">The <see cref="string"/> to be appended.</param>
|
||||
/// <returns>A reference to this instance after the append operation has completed.</returns>
|
||||
public abstract TagHelperContent AppendEncoded(string value);
|
||||
public abstract TagHelperContent AppendHtml(string encoded);
|
||||
|
||||
/// <summary>
|
||||
/// Appends the specified <paramref name="format"/> to the existing content after
|
||||
|
|
@ -157,9 +157,9 @@ namespace Microsoft.AspNet.Razor.TagHelpers
|
|||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
IHtmlContentBuilder IHtmlContentBuilder.AppendEncoded(string encoded)
|
||||
IHtmlContentBuilder IHtmlContentBuilder.AppendHtml(string encoded)
|
||||
{
|
||||
return AppendEncoded(encoded);
|
||||
return AppendHtml(encoded);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
|
|
|||
|
|
@ -39,6 +39,33 @@ namespace Microsoft.AspNet.Razor.TagHelpers
|
|||
Assert.Equal(expected, tagHelperContent.GetContent(new CommonTestEncoder()));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SetHtmlContent_TextIsNotFurtherEncoded()
|
||||
{
|
||||
// Arrange
|
||||
var tagHelperContent = new DefaultTagHelperContent();
|
||||
|
||||
// Act
|
||||
tagHelperContent.SetHtmlContent("Hi");
|
||||
|
||||
// Assert
|
||||
Assert.Equal("Hi", tagHelperContent.GetContent(new CommonTestEncoder()));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SetHtmlContent_ClearsExistingContent()
|
||||
{
|
||||
// Arrange
|
||||
var tagHelperContent = new DefaultTagHelperContent();
|
||||
tagHelperContent.AppendHtml("Contoso");
|
||||
|
||||
// Act
|
||||
tagHelperContent.SetHtmlContent("Hello World!");
|
||||
|
||||
// Assert
|
||||
Assert.Equal("Hello World!", tagHelperContent.GetContent(new CommonTestEncoder()));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("HelloWorld!", "HtmlEncode[[HelloWorld!]]")]
|
||||
[InlineData(" ", "HtmlEncode[[ ]]")]
|
||||
|
|
@ -473,11 +500,11 @@ namespace Microsoft.AspNet.Razor.TagHelpers
|
|||
}
|
||||
|
||||
[Fact]
|
||||
public void AppendEncoded_DoesNotGetEncoded()
|
||||
public void AppendHtml_DoesNotGetEncoded()
|
||||
{
|
||||
// Arrange
|
||||
var tagHelperContent = new DefaultTagHelperContent();
|
||||
tagHelperContent.AppendEncoded("Hi");
|
||||
tagHelperContent.AppendHtml("Hi");
|
||||
|
||||
var writer = new StringWriter();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue