Fix #2488 - add ability to include inline script resource definitions in modules and themes
This commit is contained in:
		| @ -72,15 +72,24 @@ namespace Oqtane.Modules | ||||
|             { | ||||
|                 if (Resources != null && Resources.Exists(item => item.ResourceType == ResourceType.Script)) | ||||
|                 { | ||||
|                     var interop = new Interop(JSRuntime); | ||||
|                     var scripts = new List<object>(); | ||||
|                     var inline = 0; | ||||
|                     foreach (Resource resource in Resources.Where(item => item.ResourceType == ResourceType.Script)) | ||||
|                     { | ||||
|                         var url = (resource.Url.Contains("://")) ? resource.Url : PageState.Alias.BaseUrl + resource.Url; | ||||
|                         scripts.Add(new { href = url, bundle = resource.Bundle ?? "", integrity = resource.Integrity ?? "", crossorigin = resource.CrossOrigin ?? "", es6module = resource.ES6Module }); | ||||
|                         if (!string.IsNullOrEmpty(resource.Url)) | ||||
|                         { | ||||
|                             var url = (resource.Url.Contains("://")) ? resource.Url : PageState.Alias.BaseUrl + resource.Url; | ||||
|                             scripts.Add(new { href = url, bundle = resource.Bundle ?? "", integrity = resource.Integrity ?? "", crossorigin = resource.CrossOrigin ?? "", es6module = resource.ES6Module }); | ||||
|                         } | ||||
|                         else | ||||
|                         { | ||||
|                             inline += 1; | ||||
|                             await interop.IncludeScript(GetType().Namespace.ToLower() + inline.ToString(), "", "", "", resource.Content, resource.Location.ToString().ToLower()); | ||||
|                         } | ||||
|                     } | ||||
|                     if (scripts.Any()) | ||||
|                     { | ||||
|                         var interop = new Interop(JSRuntime); | ||||
|                         await interop.IncludeScripts(scripts.ToArray()); | ||||
|                     } | ||||
|                 } | ||||
|  | ||||
| @ -32,15 +32,24 @@ namespace Oqtane.Themes | ||||
|             { | ||||
|                 if (Resources != null && Resources.Exists(item => item.ResourceType == ResourceType.Script)) | ||||
|                 { | ||||
|                     var interop = new Interop(JSRuntime); | ||||
|                     var scripts = new List<object>(); | ||||
|                     var inline = 0; | ||||
|                     foreach (Resource resource in Resources.Where(item => item.ResourceType == ResourceType.Script)) | ||||
|                     { | ||||
|                         var url = (resource.Url.Contains("://")) ? resource.Url : PageState.Alias.BaseUrl + resource.Url; | ||||
|                         scripts.Add(new { href = url, bundle = resource.Bundle ?? "", integrity = resource.Integrity ?? "", crossorigin = resource.CrossOrigin ?? "", es6module = resource.ES6Module }); | ||||
|                         if (!string.IsNullOrEmpty(resource.Url)) | ||||
|                         { | ||||
|                             var url = (resource.Url.Contains("://")) ? resource.Url : PageState.Alias.BaseUrl + resource.Url; | ||||
|                             scripts.Add(new { href = url, bundle = resource.Bundle ?? "", integrity = resource.Integrity ?? "", crossorigin = resource.CrossOrigin ?? "", es6module = resource.ES6Module }); | ||||
|                         } | ||||
|                         else | ||||
|                         { | ||||
|                             inline += 1; | ||||
|                             await interop.IncludeScript(GetType().Namespace.ToLower() + inline.ToString(), "", "", "", resource.Content, resource.Location.ToString().ToLower()); | ||||
|                         } | ||||
|                     } | ||||
|                     if (scripts.Any()) | ||||
|                     { | ||||
|                         var interop = new Interop(JSRuntime); | ||||
|                         await interop.IncludeScripts(scripts.ToArray()); | ||||
|                     } | ||||
|                 } | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 Shaun Walker
					Shaun Walker