fix #5988 - add inline script support to static rendering
This commit is contained in:
@@ -227,38 +227,4 @@
|
||||
}
|
||||
return stylesheets;
|
||||
}
|
||||
|
||||
private string ManageScripts(List<Resource> resources, Alias alias)
|
||||
{
|
||||
var scripts = "";
|
||||
if (resources != null)
|
||||
{
|
||||
foreach (var resource in resources.Where(item => item.ResourceType == ResourceType.Script && item.Location == ResourceLocation.Head))
|
||||
{
|
||||
var script = CreateScript(resource, alias);
|
||||
if (!scripts.Contains(script, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
scripts += script + Environment.NewLine;
|
||||
}
|
||||
}
|
||||
}
|
||||
return scripts;
|
||||
}
|
||||
|
||||
private string CreateScript(Resource resource, Alias alias)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(resource.Url))
|
||||
{
|
||||
var url = (resource.Url.Contains("://")) ? resource.Url : alias.BaseUrl + resource.Url;
|
||||
return "<script src=\"" + url + "\"" +
|
||||
((!string.IsNullOrEmpty(resource.Integrity)) ? " integrity=\"" + resource.Integrity + "\"" : "") +
|
||||
((!string.IsNullOrEmpty(resource.CrossOrigin)) ? " crossorigin=\"" + resource.CrossOrigin + "\"" : "") +
|
||||
"></script>";
|
||||
}
|
||||
else
|
||||
{
|
||||
// inline script
|
||||
return "<script>" + resource.Content + "</script>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user