diff --git a/src/OrchardCore/OrchardCore.ResourceManagement/TagHelpers/ScriptTagHelper.cs b/src/OrchardCore/OrchardCore.ResourceManagement/TagHelpers/ScriptTagHelper.cs
index d751fb9769e..a28a1d21315 100644
--- a/src/OrchardCore/OrchardCore.ResourceManagement/TagHelpers/ScriptTagHelper.cs
+++ b/src/OrchardCore/OrchardCore.ResourceManagement/TagHelpers/ScriptTagHelper.cs
@@ -54,19 +54,19 @@ public override async Task ProcessAsync(TagHelperContext context, TagHelperOutpu
if (!hasName && hasSource)
{
- //
+ //
RequireSettings setting;
if (string.IsNullOrEmpty(DependsOn))
{
- // Include custom script url
+ // Include custom script url.
setting = _resourceManager.RegisterUrl("script", Src, DebugSrc);
}
else
{
- // Anonymous declaration with dependencies, then display
+ // Anonymous declaration with dependencies, then display.
- // Using the source as the name to prevent duplicate references to the same file
+ // Using the source as the name to prevent duplicate references to the same file.
var name = Src.ToLowerInvariant();
PopulateResourceDefinition(_resourceManager.InlineManifest.DefineScript(name));
@@ -88,8 +88,8 @@ public override async Task ProcessAsync(TagHelperContext context, TagHelperOutpu
}
else if (hasName && !hasSource)
{
- // Resource required
- //
+ // Resource required.
+ //
var setting = _resourceManager.RegisterResource("script", Name);
@@ -108,7 +108,7 @@ public override async Task ProcessAsync(TagHelperContext context, TagHelperOutpu
// This allows additions to the pre registered scripts dependencies.
if (!string.IsNullOrEmpty(DependsOn))
{
- setting.SetDependencies(DependsOn.Split(_separator, StringSplitOptions.RemoveEmptyEntries));
+ setting.SetDependencies(DependsOn.Split(_separator, StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries));
}
// Allow Inline to work with both named scripts, and named inline scripts.
@@ -118,7 +118,7 @@ public override async Task ProcessAsync(TagHelperContext context, TagHelperOutpu
var childContent = await output.GetChildContentAsync();
if (!childContent.IsEmptyOrWhiteSpace)
{
- // Inline content definition
+ // Inline content definition.
_resourceManager.InlineManifest.DefineScript(Name)
.SetInnerContent(childContent.GetContent());
}
@@ -135,11 +135,11 @@ public override async Task ProcessAsync(TagHelperContext context, TagHelperOutpu
}
else if (hasName && hasSource)
{
- // Inline declaration
+ // Inline declaration.
PopulateResourceDefinition(_resourceManager.InlineManifest.DefineScript(Name));
- // If At is specified then we also render it
+ // If At is specified then we also render it.
if (At != ResourceLocation.Unspecified)
{
var setting = _resourceManager.RegisterResource("script", Name);
@@ -154,10 +154,32 @@ public override async Task ProcessAsync(TagHelperContext context, TagHelperOutpu
}
else
{
- // Custom script content
+ // Custom script content.
+ //
var childContent = await output.GetChildContentAsync();
+ if (!string.IsNullOrEmpty(DependsOn))
+ {
+ var dependencies = DependsOn.Split(_separator, StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries);
+
+ foreach (var dependency in dependencies)
+ {
+ var versionParts = dependency.Split(':');
+
+ var resourceName = versionParts[0];
+
+ var script = _resourceManager.RegisterResource("script", resourceName);
+
+ if (versionParts.Length == 2)
+ {
+ script.Version = versionParts[1];
+ }
+
+ script.AtLocation(At);
+ }
+ }
+
var builder = new TagBuilder("script");
builder.InnerHtml.AppendHtml(childContent);
builder.TagRenderMode = TagRenderMode.Normal;
@@ -198,7 +220,7 @@ private void PopulateResourceDefinition(ResourceDefinition definition)
if (!string.IsNullOrEmpty(DependsOn))
{
- definition.SetDependencies(DependsOn.Split(_separator, StringSplitOptions.RemoveEmptyEntries));
+ definition.SetDependencies(DependsOn.Split(_separator, StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries));
}
if (AppendVersion.HasValue)
diff --git a/src/OrchardCore/OrchardCore.ResourceManagement/TagHelpers/StyleTagHelper.cs b/src/OrchardCore/OrchardCore.ResourceManagement/TagHelpers/StyleTagHelper.cs
index b3e4bf83b50..413175fb279 100644
--- a/src/OrchardCore/OrchardCore.ResourceManagement/TagHelpers/StyleTagHelper.cs
+++ b/src/OrchardCore/OrchardCore.ResourceManagement/TagHelpers/StyleTagHelper.cs
@@ -48,9 +48,14 @@ public override async Task ProcessAsync(TagHelperContext context, TagHelperOutpu
{
output.SuppressOutput();
- if (string.IsNullOrEmpty(Name) && !string.IsNullOrEmpty(Src))
+ var hasName = !string.IsNullOrEmpty(Name);
+ var hasSource = !string.IsNullOrEmpty(Src);
+
+ if (!hasName && hasSource)
{
- // Include custom style
+ // Include custom style.
+ //
+
var setting = _resourceManager.RegisterUrl("stylesheet", Src, DebugSrc);
foreach (var attribute in output.Attributes)
@@ -89,7 +94,7 @@ public override async Task ProcessAsync(TagHelperContext context, TagHelperOutpu
if (!string.IsNullOrEmpty(DependsOn))
{
- setting.SetDependencies(DependsOn.Split(_splitSeparators, StringSplitOptions.RemoveEmptyEntries));
+ setting.SetDependencies(DependsOn.Split(_splitSeparators, StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries));
}
if (At == ResourceLocation.Inline)
@@ -99,9 +104,10 @@ public override async Task ProcessAsync(TagHelperContext context, TagHelperOutpu
output.Content.AppendHtml(sw.ToString());
}
}
- else if (!string.IsNullOrEmpty(Name) && string.IsNullOrEmpty(Src))
+ else if (hasName && !hasSource)
{
- // Resource required
+ // Resource required.
+ //
var setting = _resourceManager.RegisterResource("stylesheet", Name);
@@ -152,13 +158,13 @@ public override async Task ProcessAsync(TagHelperContext context, TagHelperOutpu
// This allows additions to the pre registered style dependencies.
if (!string.IsNullOrEmpty(DependsOn))
{
- setting.SetDependencies(DependsOn.Split(_splitSeparators, StringSplitOptions.RemoveEmptyEntries));
+ setting.SetDependencies(DependsOn.Split(_splitSeparators, StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries));
}
var childContent = await output.GetChildContentAsync();
if (!childContent.IsEmptyOrWhiteSpace)
{
- // Inline named style definition
+ // Inline named style definition.
_resourceManager.InlineManifest.DefineStyle(Name)
.SetInnerContent(childContent.GetContent());
}
@@ -170,9 +176,9 @@ public override async Task ProcessAsync(TagHelperContext context, TagHelperOutpu
output.Content.AppendHtml(sw.ToString());
}
}
- else if (!string.IsNullOrEmpty(Name) && !string.IsNullOrEmpty(Src))
+ else if (hasName && hasSource)
{
- // Inline declaration
+ // Inline declaration.
var definition = _resourceManager.InlineManifest.DefineStyle(Name);
definition.SetUrl(Src, DebugSrc);
@@ -194,12 +200,12 @@ public override async Task ProcessAsync(TagHelperContext context, TagHelperOutpu
if (!string.IsNullOrEmpty(Culture))
{
- definition.SetCultures(Culture.Split(',', StringSplitOptions.RemoveEmptyEntries));
+ definition.SetCultures(Culture.Split(',', StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries));
}
if (!string.IsNullOrEmpty(DependsOn))
{
- definition.SetDependencies(DependsOn.Split(',', StringSplitOptions.RemoveEmptyEntries));
+ definition.SetDependencies(DependsOn.Split(',', StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries));
}
// Also include the style.
@@ -241,12 +247,34 @@ public override async Task ProcessAsync(TagHelperContext context, TagHelperOutpu
output.Content.AppendHtml(sw.ToString());
}
}
- else if (string.IsNullOrEmpty(Name) && string.IsNullOrEmpty(Src))
+ else
{
- // Custom style content
+ // Custom style content.
+ //
var childContent = await output.GetChildContentAsync();
+ if (!string.IsNullOrEmpty(DependsOn))
+ {
+ var dependencies = DependsOn.Split(',', StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries);
+
+ foreach (var dependency in dependencies)
+ {
+ var versionParts = dependency.Split(':');
+
+ var resourceName = versionParts[0];
+
+ var style = _resourceManager.RegisterResource("stylesheet", resourceName);
+
+ if (versionParts.Length == 2)
+ {
+ style.Version = versionParts[1];
+ }
+
+ style.AtLocation(At);
+ }
+ }
+
var builder = new TagBuilder("style");
builder.InnerHtml.AppendHtml(childContent);
builder.TagRenderMode = TagRenderMode.Normal;
@@ -256,7 +284,7 @@ public override async Task ProcessAsync(TagHelperContext context, TagHelperOutpu
builder.Attributes.Add(attribute.Name, attribute.Value.ToString());
}
- // If no type was specified, define a default one
+ // If no type was specified, define a default one.
if (!builder.Attributes.ContainsKey("type"))
{
builder.Attributes.Add("type", "text/css");