Renamed FileVersion to AppendVersion in tag helpers that support cache busting

FileVersion property renamed to AppendVersion in ImageTagHelper,
LinkTagHelper and ScriptTagHelper.

asp-file-version attribute renamed to asp-append-version.

Resolves issue #2540
This commit is contained in:
David Paquette 2015-05-18 11:36:52 -05:00 committed by Doug Bunting
parent 6e1226bfe4
commit 3fe0490b99
9 changed files with 80 additions and 80 deletions

View File

@ -15,12 +15,12 @@ namespace Microsoft.AspNet.Mvc.TagHelpers
/// <remarks> /// <remarks>
/// The tag helper won't process for cases with just the 'src' attribute. /// The tag helper won't process for cases with just the 'src' attribute.
/// </remarks> /// </remarks>
[TargetElement("img", Attributes = FileVersionAttributeName + "," + SrcAttributeName)] [TargetElement("img", Attributes = AppendVersionAttributeName + "," + SrcAttributeName)]
public class ImageTagHelper : TagHelper public class ImageTagHelper : TagHelper
{ {
private static readonly string Namespace = typeof(ImageTagHelper).Namespace; private static readonly string Namespace = typeof(ImageTagHelper).Namespace;
private const string FileVersionAttributeName = "asp-file-version"; private const string AppendVersionAttributeName = "asp-append-version";
private const string SrcAttributeName = "src"; private const string SrcAttributeName = "src";
private FileVersionProvider _fileVersionProvider; private FileVersionProvider _fileVersionProvider;
@ -51,8 +51,8 @@ namespace Microsoft.AspNet.Mvc.TagHelpers
/// <remarks> /// <remarks>
/// If <c>true</c> then a query string "v" with the encoded content of the file is added. /// If <c>true</c> then a query string "v" with the encoded content of the file is added.
/// </remarks> /// </remarks>
[HtmlAttributeName(FileVersionAttributeName)] [HtmlAttributeName(AppendVersionAttributeName)]
public bool FileVersion { get; set; } public bool AppendVersion { get; set; }
protected IHostingEnvironment HostingEnvironment { get; } protected IHostingEnvironment HostingEnvironment { get; }
@ -64,7 +64,7 @@ namespace Microsoft.AspNet.Mvc.TagHelpers
/// <inheritdoc /> /// <inheritdoc />
public override void Process(TagHelperContext context, TagHelperOutput output) public override void Process(TagHelperContext context, TagHelperOutput output)
{ {
if (FileVersion) if (AppendVersion)
{ {
EnsureFileVersionProvider(); EnsureFileVersionProvider();
output.Attributes[SrcAttributeName] = _fileVersionProvider.AddFileVersionToPath(Src); output.Attributes[SrcAttributeName] = _fileVersionProvider.AddFileVersionToPath(Src);

View File

@ -29,7 +29,7 @@ namespace Microsoft.AspNet.Mvc.TagHelpers
[TargetElement("link", Attributes = FallbackTestClassAttributeName)] [TargetElement("link", Attributes = FallbackTestClassAttributeName)]
[TargetElement("link", Attributes = FallbackTestPropertyAttributeName)] [TargetElement("link", Attributes = FallbackTestPropertyAttributeName)]
[TargetElement("link", Attributes = FallbackTestValueAttributeName)] [TargetElement("link", Attributes = FallbackTestValueAttributeName)]
[TargetElement("link", Attributes = FileVersionAttributeName)] [TargetElement("link", Attributes = AppendVersionAttributeName)]
public class LinkTagHelper : TagHelper public class LinkTagHelper : TagHelper
{ {
private static readonly string Namespace = typeof(LinkTagHelper).Namespace; private static readonly string Namespace = typeof(LinkTagHelper).Namespace;
@ -43,14 +43,14 @@ namespace Microsoft.AspNet.Mvc.TagHelpers
private const string FallbackTestPropertyAttributeName = "asp-fallback-test-property"; private const string FallbackTestPropertyAttributeName = "asp-fallback-test-property";
private const string FallbackTestValueAttributeName = "asp-fallback-test-value"; private const string FallbackTestValueAttributeName = "asp-fallback-test-value";
private readonly string FallbackJavaScriptResourceName = Namespace + ".compiler.resources.LinkTagHelper_FallbackJavaScript.js"; private readonly string FallbackJavaScriptResourceName = Namespace + ".compiler.resources.LinkTagHelper_FallbackJavaScript.js";
private const string FileVersionAttributeName = "asp-file-version"; private const string AppendVersionAttributeName = "asp-append-version";
private const string HrefAttributeName = "href"; private const string HrefAttributeName = "href";
private FileVersionProvider _fileVersionProvider; private FileVersionProvider _fileVersionProvider;
private static readonly ModeAttributes<Mode>[] ModeDetails = new[] { private static readonly ModeAttributes<Mode>[] ModeDetails = new[] {
// Regular src with file version alone // Regular src with file version alone
ModeAttributes.Create(Mode.FileVersion, new[] { FileVersionAttributeName }), ModeAttributes.Create(Mode.AppendVersion, new[] { AppendVersionAttributeName }),
// Globbed Href (include only) no static href // Globbed Href (include only) no static href
ModeAttributes.Create(Mode.GlobbedHref, new [] { HrefIncludeAttributeName }), ModeAttributes.Create(Mode.GlobbedHref, new [] { HrefIncludeAttributeName }),
// Globbed Href (include & exclude), no static href // Globbed Href (include & exclude), no static href
@ -141,8 +141,8 @@ namespace Microsoft.AspNet.Mvc.TagHelpers
/// <remarks> /// <remarks>
/// If <c>true</c> then a query string "v" with the encoded content of the file is added. /// If <c>true</c> then a query string "v" with the encoded content of the file is added.
/// </remarks> /// </remarks>
[HtmlAttributeName(FileVersionAttributeName)] [HtmlAttributeName(AppendVersionAttributeName)]
public bool? FileVersion { get; set; } public bool? AppendVersion { get; set; }
/// <summary> /// <summary>
/// A comma separated list of globbed file patterns of CSS stylesheets to fallback to in the case the primary /// A comma separated list of globbed file patterns of CSS stylesheets to fallback to in the case the primary
@ -229,7 +229,7 @@ namespace Microsoft.AspNet.Mvc.TagHelpers
var builder = new DefaultTagHelperContent(); var builder = new DefaultTagHelperContent();
if (mode == Mode.Fallback && string.IsNullOrEmpty(HrefInclude) || mode == Mode.FileVersion) if (mode == Mode.Fallback && string.IsNullOrEmpty(HrefInclude) || mode == Mode.AppendVersion)
{ {
// No globbing to do, just build a <link /> tag to match the original one in the source file. // No globbing to do, just build a <link /> tag to match the original one in the source file.
// Or just add file version to the link tag. // Or just add file version to the link tag.
@ -274,7 +274,7 @@ namespace Microsoft.AspNet.Mvc.TagHelpers
if (fallbackHrefs.Length > 0) if (fallbackHrefs.Length > 0)
{ {
if (FileVersion == true) if (AppendVersion == true)
{ {
for (var i=0; i < fallbackHrefs.Length; i++) for (var i=0; i < fallbackHrefs.Length; i++)
{ {
@ -338,7 +338,7 @@ namespace Microsoft.AspNet.Mvc.TagHelpers
foreach (var attribute in attributes) foreach (var attribute in attributes)
{ {
var attributeValue = attribute.Value; var attributeValue = attribute.Value;
if (FileVersion == true && if (AppendVersion == true &&
string.Equals(attribute.Name, HrefAttributeName, StringComparison.OrdinalIgnoreCase)) string.Equals(attribute.Name, HrefAttributeName, StringComparison.OrdinalIgnoreCase))
{ {
// "href" values come from bound attributes and globbing. So anything but a non-null string is // "href" values come from bound attributes and globbing. So anything but a non-null string is
@ -366,7 +366,7 @@ namespace Microsoft.AspNet.Mvc.TagHelpers
/// <summary> /// <summary>
/// Just adding a file version for the generated urls. /// Just adding a file version for the generated urls.
/// </summary> /// </summary>
FileVersion = 0, AppendVersion = 0,
/// <summary> /// <summary>
/// Just performing file globbing search for the href, rendering a separate &lt;link&gt; for each match. /// Just performing file globbing search for the href, rendering a separate &lt;link&gt; for each match.

View File

@ -27,7 +27,7 @@ namespace Microsoft.AspNet.Mvc.TagHelpers
[TargetElement("script", Attributes = FallbackSrcIncludeAttributeName)] [TargetElement("script", Attributes = FallbackSrcIncludeAttributeName)]
[TargetElement("script", Attributes = FallbackSrcExcludeAttributeName)] [TargetElement("script", Attributes = FallbackSrcExcludeAttributeName)]
[TargetElement("script", Attributes = FallbackTestExpressionAttributeName)] [TargetElement("script", Attributes = FallbackTestExpressionAttributeName)]
[TargetElement("script", Attributes = FileVersionAttributeName)] [TargetElement("script", Attributes = AppendVersionAttributeName)]
public class ScriptTagHelper : TagHelper public class ScriptTagHelper : TagHelper
{ {
private const string SrcIncludeAttributeName = "asp-src-include"; private const string SrcIncludeAttributeName = "asp-src-include";
@ -37,13 +37,13 @@ namespace Microsoft.AspNet.Mvc.TagHelpers
private const string FallbackSrcExcludeAttributeName = "asp-fallback-src-exclude"; private const string FallbackSrcExcludeAttributeName = "asp-fallback-src-exclude";
private const string FallbackTestExpressionAttributeName = "asp-fallback-test"; private const string FallbackTestExpressionAttributeName = "asp-fallback-test";
private const string SrcAttributeName = "src"; private const string SrcAttributeName = "src";
private const string FileVersionAttributeName = "asp-file-version"; private const string AppendVersionAttributeName = "asp-append-version";
private FileVersionProvider _fileVersionProvider; private FileVersionProvider _fileVersionProvider;
private static readonly ModeAttributes<Mode>[] ModeDetails = new[] { private static readonly ModeAttributes<Mode>[] ModeDetails = new[] {
// Regular src with file version alone // Regular src with file version alone
ModeAttributes.Create(Mode.FileVersion, new[] { FileVersionAttributeName }), ModeAttributes.Create(Mode.AppendVersion, new[] { AppendVersionAttributeName }),
// Globbed src (include only) // Globbed src (include only)
ModeAttributes.Create(Mode.GlobbedSrc, new [] { SrcIncludeAttributeName }), ModeAttributes.Create(Mode.GlobbedSrc, new [] { SrcIncludeAttributeName }),
// Globbed src (include & exclude) // Globbed src (include & exclude)
@ -128,8 +128,8 @@ namespace Microsoft.AspNet.Mvc.TagHelpers
/// <remarks> /// <remarks>
/// A query string "v" with the encoded content of the file is added. /// A query string "v" with the encoded content of the file is added.
/// </remarks> /// </remarks>
[HtmlAttributeName(FileVersionAttributeName)] [HtmlAttributeName(AppendVersionAttributeName)]
public bool? FileVersion { get; set; } public bool? AppendVersion { get; set; }
/// <summary> /// <summary>
/// A comma separated list of globbed file patterns of JavaScript scripts to fallback to in the case the /// A comma separated list of globbed file patterns of JavaScript scripts to fallback to in the case the
@ -199,7 +199,7 @@ namespace Microsoft.AspNet.Mvc.TagHelpers
var builder = new DefaultTagHelperContent(); var builder = new DefaultTagHelperContent();
var originalContent = await context.GetChildContentAsync(); var originalContent = await context.GetChildContentAsync();
if (mode == Mode.Fallback && string.IsNullOrEmpty(SrcInclude) || mode == Mode.FileVersion) if (mode == Mode.Fallback && string.IsNullOrEmpty(SrcInclude) || mode == Mode.AppendVersion)
{ {
// No globbing to do, just build a <script /> tag to match the original one in the source file // No globbing to do, just build a <script /> tag to match the original one in the source file
// Or just add file version to the script tag. // Or just add file version to the script tag.
@ -288,7 +288,7 @@ namespace Microsoft.AspNet.Mvc.TagHelpers
{ {
// Ignore attribute.Value; use src instead. // Ignore attribute.Value; use src instead.
var attributeValue = src; var attributeValue = src;
if (FileVersion == true) if (AppendVersion == true)
{ {
attributeValue = _fileVersionProvider.AddFileVersionToPath(attributeValue); attributeValue = _fileVersionProvider.AddFileVersionToPath(attributeValue);
} }
@ -340,7 +340,7 @@ namespace Microsoft.AspNet.Mvc.TagHelpers
foreach (var attribute in attributes) foreach (var attribute in attributes)
{ {
var attributeValue = attribute.Value; var attributeValue = attribute.Value;
if (FileVersion == true && if (AppendVersion == true &&
string.Equals(attribute.Name, SrcAttributeName, StringComparison.OrdinalIgnoreCase)) string.Equals(attribute.Name, SrcAttributeName, StringComparison.OrdinalIgnoreCase))
{ {
// "src" values come from bound attributes and globbing. So anything but a non-null string is // "src" values come from bound attributes and globbing. So anything but a non-null string is
@ -389,7 +389,7 @@ namespace Microsoft.AspNet.Mvc.TagHelpers
/// <summary> /// <summary>
/// Just adding a file version for the generated urls. /// Just adding a file version for the generated urls.
/// </summary> /// </summary>
FileVersion = 0, AppendVersion = 0,
/// <summary> /// <summary>
/// Just performing file globbing search for the src, rendering a separate &lt;script&gt; for each match. /// Just performing file globbing search for the src, rendering a separate &lt;script&gt; for each match.

View File

@ -35,7 +35,7 @@ namespace Microsoft.AspNet.Mvc.TagHelpers
{ "data-extra", new HtmlString("something") }, { "data-extra", new HtmlString("something") },
{ "title", new HtmlString("Image title") }, { "title", new HtmlString("Image title") },
{ "src", "testimage.png" }, { "src", "testimage.png" },
{ "asp-file-version", "true" } { "asp-append-version", "true" }
}); });
var output = MakeImageTagHelperOutput( var output = MakeImageTagHelperOutput(
attributes: new TagHelperAttributeList attributes: new TagHelperAttributeList
@ -61,7 +61,7 @@ namespace Microsoft.AspNet.Mvc.TagHelpers
{ {
ViewContext = viewContext, ViewContext = viewContext,
Src = "testimage.png", Src = "testimage.png",
FileVersion = true, AppendVersion = true,
}; };
// Act // Act
@ -89,7 +89,7 @@ namespace Microsoft.AspNet.Mvc.TagHelpers
{ {
{ "alt", new HtmlString("Alt image text") }, { "alt", new HtmlString("Alt image text") },
{ "src", "/images/test-image.png" }, { "src", "/images/test-image.png" },
{ "asp-file-version", "true" } { "asp-append-version", "true" }
}); });
var output = MakeImageTagHelperOutput(attributes: new TagHelperAttributeList var output = MakeImageTagHelperOutput(attributes: new TagHelperAttributeList
{ {
@ -102,7 +102,7 @@ namespace Microsoft.AspNet.Mvc.TagHelpers
{ {
ViewContext = viewContext, ViewContext = viewContext,
Src = "/images/test-image.png", Src = "/images/test-image.png",
FileVersion = true, AppendVersion = true
}; };
// Act // Act
@ -125,7 +125,7 @@ namespace Microsoft.AspNet.Mvc.TagHelpers
{ {
{ "alt", new HtmlString("Alt image text") }, { "alt", new HtmlString("Alt image text") },
{ "src", "/images/test-image.png" }, { "src", "/images/test-image.png" },
{ "asp-file-version", "false" } { "asp-append-version", "false" }
}); });
var output = MakeImageTagHelperOutput(attributes: new TagHelperAttributeList var output = MakeImageTagHelperOutput(attributes: new TagHelperAttributeList
{ {
@ -138,7 +138,7 @@ namespace Microsoft.AspNet.Mvc.TagHelpers
{ {
ViewContext = viewContext, ViewContext = viewContext,
Src = "/images/test-image.png", Src = "/images/test-image.png",
FileVersion = false, AppendVersion = false
}; };
// Act // Act
@ -161,7 +161,7 @@ namespace Microsoft.AspNet.Mvc.TagHelpers
{ {
{ "alt", new HtmlString("alt text") }, { "alt", new HtmlString("alt text") },
{ "src", "/bar/images/image.jpg" }, { "src", "/bar/images/image.jpg" },
{ "asp-file-version", "true" }, { "asp-append-version", "true" },
}); });
var output = MakeImageTagHelperOutput(attributes: new TagHelperAttributeList var output = MakeImageTagHelperOutput(attributes: new TagHelperAttributeList
{ {
@ -174,7 +174,7 @@ namespace Microsoft.AspNet.Mvc.TagHelpers
{ {
ViewContext = viewContext, ViewContext = viewContext,
Src = "/bar/images/image.jpg", Src = "/bar/images/image.jpg",
FileVersion = true, AppendVersion = true
}; };
// Act // Act

View File

@ -196,23 +196,23 @@ namespace Microsoft.AspNet.Mvc.TagHelpers
{ {
new TagHelperAttributeList new TagHelperAttributeList
{ {
["asp-file-version"] = "true" ["asp-append-version"] = "true"
}, },
tagHelper => tagHelper =>
{ {
tagHelper.FileVersion = true; tagHelper.AppendVersion = true;
} }
}, },
{ {
new TagHelperAttributeList new TagHelperAttributeList
{ {
["asp-href-include"] = "*.css", ["asp-href-include"] = "*.css",
["asp-file-version"] = "true" ["asp-append-version"] = "true"
}, },
tagHelper => tagHelper =>
{ {
tagHelper.HrefInclude = "*.css"; tagHelper.HrefInclude = "*.css";
tagHelper.FileVersion = true; tagHelper.AppendVersion = true;
} }
}, },
{ {
@ -220,13 +220,13 @@ namespace Microsoft.AspNet.Mvc.TagHelpers
{ {
["asp-href-include"] = "*.css", ["asp-href-include"] = "*.css",
["asp-href-exclude"] = "*.min.css", ["asp-href-exclude"] = "*.min.css",
["asp-file-version"] = "true" ["asp-append-version"] = "true"
}, },
tagHelper => tagHelper =>
{ {
tagHelper.HrefInclude = "*.css"; tagHelper.HrefInclude = "*.css";
tagHelper.HrefExclude = "*.min.css"; tagHelper.HrefExclude = "*.min.css";
tagHelper.FileVersion = true; tagHelper.AppendVersion = true;
} }
}, },
{ {
@ -236,7 +236,7 @@ namespace Microsoft.AspNet.Mvc.TagHelpers
["asp-fallback-test-class"] = "hidden", ["asp-fallback-test-class"] = "hidden",
["asp-fallback-test-property"] = "visibility", ["asp-fallback-test-property"] = "visibility",
["asp-fallback-test-value"] = "hidden", ["asp-fallback-test-value"] = "hidden",
["asp-file-version"] = "true" ["asp-append-version"] = "true"
}, },
tagHelper => tagHelper =>
{ {
@ -244,7 +244,7 @@ namespace Microsoft.AspNet.Mvc.TagHelpers
tagHelper.FallbackTestClass = "hidden"; tagHelper.FallbackTestClass = "hidden";
tagHelper.FallbackTestProperty = "visibility"; tagHelper.FallbackTestProperty = "visibility";
tagHelper.FallbackTestValue = "hidden"; tagHelper.FallbackTestValue = "hidden";
tagHelper.FileVersion = true; tagHelper.AppendVersion = true;
} }
}, },
{ {
@ -254,7 +254,7 @@ namespace Microsoft.AspNet.Mvc.TagHelpers
["asp-fallback-test-class"] = "hidden", ["asp-fallback-test-class"] = "hidden",
["asp-fallback-test-property"] = "visibility", ["asp-fallback-test-property"] = "visibility",
["asp-fallback-test-value"] = "hidden", ["asp-fallback-test-value"] = "hidden",
["asp-file-version"] = "true" ["asp-append-version"] = "true"
}, },
tagHelper => tagHelper =>
{ {
@ -262,7 +262,7 @@ namespace Microsoft.AspNet.Mvc.TagHelpers
tagHelper.FallbackTestClass = "hidden"; tagHelper.FallbackTestClass = "hidden";
tagHelper.FallbackTestProperty = "visibility"; tagHelper.FallbackTestProperty = "visibility";
tagHelper.FallbackTestValue = "hidden"; tagHelper.FallbackTestValue = "hidden";
tagHelper.FileVersion = true; tagHelper.AppendVersion = true;
} }
} }
}; };
@ -581,7 +581,7 @@ namespace Microsoft.AspNet.Mvc.TagHelpers
{ {
{ "rel", new HtmlString("stylesheet") }, { "rel", new HtmlString("stylesheet") },
{ "href", "/css/site.css" }, { "href", "/css/site.css" },
{ "asp-file-version", "true" } { "asp-append-version", "true" }
}); });
var output = MakeTagHelperOutput("link", attributes: new TagHelperAttributeList var output = MakeTagHelperOutput("link", attributes: new TagHelperAttributeList
{ {
@ -601,7 +601,7 @@ namespace Microsoft.AspNet.Mvc.TagHelpers
ViewContext = viewContext, ViewContext = viewContext,
Href = "/css/site.css", Href = "/css/site.css",
HrefInclude = "**/*.css", HrefInclude = "**/*.css",
FileVersion = true, AppendVersion = true
}; };
// Act // Act
@ -622,7 +622,7 @@ namespace Microsoft.AspNet.Mvc.TagHelpers
{ {
{ "rel", new HtmlString("stylesheet") }, { "rel", new HtmlString("stylesheet") },
{ "href", "/bar/css/site.css" }, { "href", "/bar/css/site.css" },
{ "asp-file-version", "true" }, { "asp-append-version", "true" },
}); });
var output = MakeTagHelperOutput("link", attributes: new TagHelperAttributeList var output = MakeTagHelperOutput("link", attributes: new TagHelperAttributeList
{ {
@ -642,7 +642,7 @@ namespace Microsoft.AspNet.Mvc.TagHelpers
ViewContext = viewContext, ViewContext = viewContext,
Href = "/bar/css/site.css", Href = "/bar/css/site.css",
HrefInclude = "**/*.css", HrefInclude = "**/*.css",
FileVersion = true, AppendVersion = true
}; };
// Act // Act
@ -664,7 +664,7 @@ namespace Microsoft.AspNet.Mvc.TagHelpers
{ "rel", new HtmlString("stylesheet") }, { "rel", new HtmlString("stylesheet") },
{ "href", "/css/site.css" }, { "href", "/css/site.css" },
{ "asp-href-include", "**/*.css" }, { "asp-href-include", "**/*.css" },
{ "asp-file-version", "true" }, { "asp-append-version", "true" },
}); });
var output = MakeTagHelperOutput("link", attributes: new TagHelperAttributeList var output = MakeTagHelperOutput("link", attributes: new TagHelperAttributeList
{ {
@ -688,7 +688,7 @@ namespace Microsoft.AspNet.Mvc.TagHelpers
ViewContext = viewContext, ViewContext = viewContext,
Href = "/css/site.css", Href = "/css/site.css",
HrefInclude = "**/*.css", HrefInclude = "**/*.css",
FileVersion = true, AppendVersion = true
}; };
// Act // Act

View File

@ -162,23 +162,23 @@ namespace Microsoft.AspNet.Mvc.TagHelpers
{ {
new TagHelperAttributeList new TagHelperAttributeList
{ {
["asp-file-version"] = "true" ["asp-append-version"] = "true"
}, },
tagHelper => tagHelper =>
{ {
tagHelper.FileVersion = true; tagHelper.AppendVersion = true;
} }
}, },
{ {
new TagHelperAttributeList new TagHelperAttributeList
{ {
["asp-src-include"] = "*.js", ["asp-src-include"] = "*.js",
["asp-file-version"] = "true" ["asp-append-version"] = "true"
}, },
tagHelper => tagHelper =>
{ {
tagHelper.SrcInclude = "*.js"; tagHelper.SrcInclude = "*.js";
tagHelper.FileVersion = true; tagHelper.AppendVersion = true;
} }
}, },
{ {
@ -186,13 +186,13 @@ namespace Microsoft.AspNet.Mvc.TagHelpers
{ {
["asp-src-include"] = "*.js", ["asp-src-include"] = "*.js",
["asp-src-exclude"] = "*.min.js", ["asp-src-exclude"] = "*.min.js",
["asp-file-version"] = "true" ["asp-append-version"] = "true"
}, },
tagHelper => tagHelper =>
{ {
tagHelper.SrcInclude = "*.js"; tagHelper.SrcInclude = "*.js";
tagHelper.SrcExclude = "*.min.js"; tagHelper.SrcExclude = "*.min.js";
tagHelper.FileVersion = true; tagHelper.AppendVersion = true;
} }
}, },
{ {
@ -200,13 +200,13 @@ namespace Microsoft.AspNet.Mvc.TagHelpers
{ {
["asp-fallback-src"] = "test.js", ["asp-fallback-src"] = "test.js",
["asp-fallback-test"] = "isavailable()", ["asp-fallback-test"] = "isavailable()",
["asp-file-version"] = "true" ["asp-append-version"] = "true"
}, },
tagHelper => tagHelper =>
{ {
tagHelper.FallbackSrc = "test.js"; tagHelper.FallbackSrc = "test.js";
tagHelper.FallbackTestExpression = "isavailable()"; tagHelper.FallbackTestExpression = "isavailable()";
tagHelper.FileVersion = true; tagHelper.AppendVersion = true;
} }
}, },
{ {
@ -214,13 +214,13 @@ namespace Microsoft.AspNet.Mvc.TagHelpers
{ {
["asp-fallback-src-include"] = "*.js", ["asp-fallback-src-include"] = "*.js",
["asp-fallback-test"] = "isavailable()", ["asp-fallback-test"] = "isavailable()",
["asp-file-version"] = "true" ["asp-append-version"] = "true"
}, },
tagHelper => tagHelper =>
{ {
tagHelper.FallbackSrcInclude = "*.css"; tagHelper.FallbackSrcInclude = "*.css";
tagHelper.FallbackTestExpression = "isavailable()"; tagHelper.FallbackTestExpression = "isavailable()";
tagHelper.FileVersion = true; tagHelper.AppendVersion = true;
} }
}, },
{ {
@ -229,14 +229,14 @@ namespace Microsoft.AspNet.Mvc.TagHelpers
["asp-fallback-src"] = "test.js", ["asp-fallback-src"] = "test.js",
["asp-fallback-src-include"] = "*.js", ["asp-fallback-src-include"] = "*.js",
["asp-fallback-test"] = "isavailable()", ["asp-fallback-test"] = "isavailable()",
["asp-file-version"] = "true" ["asp-append-version"] = "true"
}, },
tagHelper => tagHelper =>
{ {
tagHelper.FallbackSrc = "test.js"; tagHelper.FallbackSrc = "test.js";
tagHelper.FallbackSrcInclude = "*.css"; tagHelper.FallbackSrcInclude = "*.css";
tagHelper.FallbackTestExpression = "isavailable()"; tagHelper.FallbackTestExpression = "isavailable()";
tagHelper.FileVersion = true; tagHelper.AppendVersion = true;
} }
}, },
{ {
@ -245,14 +245,14 @@ namespace Microsoft.AspNet.Mvc.TagHelpers
["asp-fallback-src-include"] = "*.js", ["asp-fallback-src-include"] = "*.js",
["asp-fallback-src-exclude"] = "*.min.js", ["asp-fallback-src-exclude"] = "*.min.js",
["asp-fallback-test"] = "isavailable()", ["asp-fallback-test"] = "isavailable()",
["asp-file-version"] = "true" ["asp-append-version"] = "true"
}, },
tagHelper => tagHelper =>
{ {
tagHelper.FallbackSrcInclude = "*.css"; tagHelper.FallbackSrcInclude = "*.css";
tagHelper.FallbackSrcExclude = "*.min.css"; tagHelper.FallbackSrcExclude = "*.min.css";
tagHelper.FallbackTestExpression = "isavailable()"; tagHelper.FallbackTestExpression = "isavailable()";
tagHelper.FileVersion = true; tagHelper.AppendVersion = true;
} }
} }
}; };
@ -625,7 +625,7 @@ namespace Microsoft.AspNet.Mvc.TagHelpers
attributes: new TagHelperAttributeList attributes: new TagHelperAttributeList
{ {
["src"] = "/js/site.js", ["src"] = "/js/site.js",
["asp-file-version"] = "true" ["asp-append-version"] = "true"
}); });
var output = MakeTagHelperOutput("script", attributes: new TagHelperAttributeList()); var output = MakeTagHelperOutput("script", attributes: new TagHelperAttributeList());
@ -641,7 +641,7 @@ namespace Microsoft.AspNet.Mvc.TagHelpers
new CommonTestEncoder()) new CommonTestEncoder())
{ {
ViewContext = viewContext, ViewContext = viewContext,
FileVersion = true, AppendVersion = true,
Src = "/js/site.js", Src = "/js/site.js",
}; };
@ -662,7 +662,7 @@ namespace Microsoft.AspNet.Mvc.TagHelpers
attributes: new TagHelperAttributeList attributes: new TagHelperAttributeList
{ {
["src"] = "/bar/js/site.js", ["src"] = "/bar/js/site.js",
["asp-file-version"] = "true" ["asp-append-version"] = "true"
}); });
var output = MakeTagHelperOutput("script", attributes: new TagHelperAttributeList()); var output = MakeTagHelperOutput("script", attributes: new TagHelperAttributeList());
@ -678,7 +678,7 @@ namespace Microsoft.AspNet.Mvc.TagHelpers
new CommonTestEncoder()) new CommonTestEncoder())
{ {
ViewContext = viewContext, ViewContext = viewContext,
FileVersion = true, AppendVersion = true,
Src = "/bar/js/site.js", Src = "/bar/js/site.js",
}; };
@ -701,7 +701,7 @@ namespace Microsoft.AspNet.Mvc.TagHelpers
["src"] = "/js/site.js", ["src"] = "/js/site.js",
["asp-fallback-src-include"] = "fallback.js", ["asp-fallback-src-include"] = "fallback.js",
["asp-fallback-test"] = "isavailable()", ["asp-fallback-test"] = "isavailable()",
["asp-file-version"] = "true" ["asp-append-version"] = "true"
}); });
var output = MakeTagHelperOutput("script", attributes: new TagHelperAttributeList()); var output = MakeTagHelperOutput("script", attributes: new TagHelperAttributeList());
@ -719,7 +719,7 @@ namespace Microsoft.AspNet.Mvc.TagHelpers
ViewContext = viewContext, ViewContext = viewContext,
FallbackSrc = "fallback.js", FallbackSrc = "fallback.js",
FallbackTestExpression = "isavailable()", FallbackTestExpression = "isavailable()",
FileVersion = true, AppendVersion = true,
Src = "/js/site.js", Src = "/js/site.js",
}; };
@ -743,7 +743,7 @@ namespace Microsoft.AspNet.Mvc.TagHelpers
{ {
["src"] = "/js/site.js", ["src"] = "/js/site.js",
["asp-src-include"] = "*.js", ["asp-src-include"] = "*.js",
["asp-file-version"] = "true" ["asp-append-version"] = "true"
}); });
var output = MakeTagHelperOutput("script", attributes: new TagHelperAttributeList()); var output = MakeTagHelperOutput("script", attributes: new TagHelperAttributeList());
var logger = new Mock<ILogger<ScriptTagHelper>>(); var logger = new Mock<ILogger<ScriptTagHelper>>();
@ -763,7 +763,7 @@ namespace Microsoft.AspNet.Mvc.TagHelpers
GlobbingUrlBuilder = globbingUrlBuilder.Object, GlobbingUrlBuilder = globbingUrlBuilder.Object,
ViewContext = viewContext, ViewContext = viewContext,
SrcInclude = "*.js", SrcInclude = "*.js",
FileVersion = true, AppendVersion = true,
Src = "/js/site.js", Src = "/js/site.js",
}; };

View File

@ -14,9 +14,9 @@
<img src="~/images/red.png" alt="Red block" title="&lt;the title>"> <img src="~/images/red.png" alt="Red block" title="&lt;the title>">
<!-- Plain image tag with file version --> <!-- Plain image tag with file version -->
<img src="~/images/red.png" alt="Red versioned" title="Red versioned" asp-file-version="true" /> <img src="~/images/red.png" alt="Red versioned" title="Red versioned" asp-append-version="true" />
<!-- Plain image tag with file version set to false --> <!-- Plain image tag with file version set to false -->
<img src="~/images/red.png" alt="Red explicitly not versioned" title="Red versioned" asp-file-version="false" /> <img src="~/images/red.png" alt="Red explicitly not versioned" title="Red versioned" asp-append-version="false" />
</body> </body>
</html> </html>

View File

@ -183,10 +183,10 @@
asp-fallback-test-property="visibility" /> asp-fallback-test-property="visibility" />
<!-- Plain link tag with file version --> <!-- Plain link tag with file version -->
<link href="~/site.css" rel="stylesheet" asp-file-version="true" /> <link href="~/site.css" rel="stylesheet" asp-append-version="true" />
<!-- Globbed link tag with existing file and file version --> <!-- Globbed link tag with existing file and file version -->
<link asp-href-include="**/site.css" rel="stylesheet" asp-file-version="true" /> <link asp-href-include="**/site.css" rel="stylesheet" asp-append-version="true" />
<!-- Fallback with file version --> <!-- Fallback with file version -->
<link href="~/site.min.css" rel="stylesheet" data-extra="test" <link href="~/site.min.css" rel="stylesheet" data-extra="test"
@ -194,10 +194,10 @@
asp-fallback-test-class="hidden" asp-fallback-test-class="hidden"
asp-fallback-test-property="visibility" asp-fallback-test-property="visibility"
asp-fallback-test-value="hidden" asp-fallback-test-value="hidden"
asp-file-version="true" /> asp-append-version="true" />
<!-- Globbed link tag with existing file, static href and file version --> <!-- Globbed link tag with existing file, static href and file version -->
<link href="~/site.css" asp-href-include="**/*.css" rel="stylesheet" asp-file-version="true" /> <link href="~/site.css" asp-href-include="**/*.css" rel="stylesheet" asp-append-version="true" />
</head> </head>
<body> <body>

View File

@ -106,25 +106,25 @@
// Globbed script tag with existing file and static src should dedupe // Globbed script tag with existing file and static src should dedupe
</script> </script>
<script src="~/blank.js" asp-fallback-src="~/site.js" asp-fallback-test="false" asp-file-version="true"> <script src="~/blank.js" asp-fallback-src="~/site.js" asp-fallback-test="false" asp-append-version="true">
// TagHelper script with comment in body, and file version. // TagHelper script with comment in body, and file version.
</script> </script>
<script src="~/blank.js" asp-fallback-src-include="**/site.js" asp-fallback-test="false" asp-file-version="true"> <script src="~/blank.js" asp-fallback-src-include="**/site.js" asp-fallback-test="false" asp-append-version="true">
// Fallback to globbed src with file version. // Fallback to globbed src with file version.
</script> </script>
<script src="~/site.js" asp-file-version="true"> <script src="~/site.js" asp-append-version="true">
// Regular script with comment in body, and file version. // Regular script with comment in body, and file version.
</script> </script>
<!-- Globbed script tag with existing files and version --> <!-- Globbed script tag with existing files and version -->
<script asp-src-include="**/*.js" asp-file-version="true"> <script asp-src-include="**/*.js" asp-append-version="true">
// This comment shouldn't be emitted // This comment shouldn't be emitted
</script> </script>
<!-- Globbed script tag with existing file, exclude and version --> <!-- Globbed script tag with existing file, exclude and version -->
<script asp-src-include="**/*.js" asp-src-exclude="**/site3.js" asp-file-version="true"> <script asp-src-include="**/*.js" asp-src-exclude="**/site3.js" asp-append-version="true">
// This comment shouldn't be emitted // This comment shouldn't be emitted
</script> </script>
</body> </body>