Improvements to add support for script type and data-* attributes. Also added Script and Stylesheet classes to simplify Resource declarations.
This commit is contained in:
@ -554,11 +554,22 @@
|
||||
if (!resource.Reload)
|
||||
{
|
||||
var url = (resource.Url.Contains("://")) ? resource.Url : alias.BaseUrl + resource.Url;
|
||||
|
||||
var dataAttributes = "";
|
||||
if (resource.DataAttributes != null && resource.DataAttributes.Count > 0)
|
||||
{
|
||||
foreach (var attribute in resource.DataAttributes)
|
||||
{
|
||||
dataAttributes += " " + attribute.Key + "=\"" + attribute.Value + "\"";
|
||||
}
|
||||
}
|
||||
|
||||
return "<script src=\"" + url + "\"" +
|
||||
((resource.ES6Module) ? " type=\"module\"" : "") +
|
||||
((!string.IsNullOrEmpty(resource.Type)) ? " type=\"" + resource.Type + "\"" : "") +
|
||||
((!string.IsNullOrEmpty(resource.Integrity)) ? " integrity=\"" + resource.Integrity + "\"" : "") +
|
||||
((!string.IsNullOrEmpty(resource.CrossOrigin)) ? " crossorigin=\"" + resource.CrossOrigin + "\"" : "") +
|
||||
"></script>";
|
||||
((!string.IsNullOrEmpty(dataAttributes)) ? dataAttributes : "") +
|
||||
"></script>";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Reference in New Issue
Block a user