ScriptTagHelper Class

Summary

Microsoft.AspNet.Razor.TagHelpers.ITagHelper implementation targeting <script> elements that supports fallback src paths.

Syntax

public class ScriptTagHelper : UrlResolutionTagHelper, ITagHelper

GitHub

View on GitHub

class Microsoft.AspNet.Mvc.TagHelpers.ScriptTagHelper

Constructors

ScriptTagHelper(Microsoft.Extensions.Logging.ILogger<Microsoft.AspNet.Mvc.TagHelpers.ScriptTagHelper>, Microsoft.AspNet.Hosting.IHostingEnvironment, Microsoft.Extensions.Caching.Memory.IMemoryCache, Microsoft.Extensions.WebEncoders.IHtmlEncoder, Microsoft.Extensions.WebEncoders.IJavaScriptStringEncoder, Microsoft.AspNet.Mvc.IUrlHelper)

Creates a new Microsoft.AspNet.Mvc.TagHelpers.ScriptTagHelper.

Arguments:
  • logger (Microsoft.Extensions.Logging.ILogger{Microsoft.AspNet.Mvc.TagHelpers.ScriptTagHelper}) – The .
  • hostingEnvironment (Microsoft.AspNet.Hosting.IHostingEnvironment) – The .
  • cache (Microsoft.Extensions.Caching.Memory.IMemoryCache) – The .
  • htmlEncoder (Microsoft.Extensions.WebEncoders.IHtmlEncoder) – The .
  • javaScriptEncoder (Microsoft.Extensions.WebEncoders.IJavaScriptStringEncoder) – The .
  • urlHelper (Microsoft.AspNet.Mvc.IUrlHelper) – The .
public ScriptTagHelper(ILogger<ScriptTagHelper> logger, IHostingEnvironment hostingEnvironment, IMemoryCache cache, IHtmlEncoder htmlEncoder, IJavaScriptStringEncoder javaScriptEncoder, IUrlHelper urlHelper)

Methods

Process(Microsoft.AspNet.Razor.TagHelpers.TagHelperContext, Microsoft.AspNet.Razor.TagHelpers.TagHelperOutput)
public override void Process(TagHelperContext context, TagHelperOutput output)

Properties

AppendVersion()

Value indicating if file version should be appended to src urls.

Return type:System.Nullable{System.Boolean}
public bool ? AppendVersion { get; set; }
Cache()
Return type:Microsoft.Extensions.Caching.Memory.IMemoryCache
protected IMemoryCache Cache { get; }
FallbackSrc()

The URL of a Script tag to fallback to in the case the primary one fails.

Return type:System.String
public string FallbackSrc { get; set; }
FallbackSrcExclude()

A comma separated list of globbed file patterns of JavaScript scripts to exclude from the fallback list, in the case the primary one fails. The glob patterns are assessed relative to the application’s ‘webroot’ setting. Must be used in conjunction with Microsoft.AspNet.Mvc.TagHelpers.ScriptTagHelper.FallbackSrcInclude.

Return type:System.String
public string FallbackSrcExclude { get; set; }
FallbackSrcInclude()

A comma separated list of globbed file patterns of JavaScript scripts to fallback to in the case the primary one fails. The glob patterns are assessed relative to the application’s ‘webroot’ setting.

Return type:System.String
public string FallbackSrcInclude { get; set; }
FallbackTestExpression()

The script method defined in the primary script to use for the fallback test.

Return type:System.String
public string FallbackTestExpression { get; set; }
GlobbingUrlBuilder()
Return type:Microsoft.AspNet.Mvc.TagHelpers.Internal.GlobbingUrlBuilder
protected GlobbingUrlBuilder GlobbingUrlBuilder { get; set; }
HostingEnvironment()
Return type:Microsoft.AspNet.Hosting.IHostingEnvironment
protected IHostingEnvironment HostingEnvironment { get; }
JavaScriptEncoder()
Return type:Microsoft.Extensions.WebEncoders.IJavaScriptStringEncoder
protected IJavaScriptStringEncoder JavaScriptEncoder { get; }
Logger()
Return type:Microsoft.Extensions.Logging.ILogger{Microsoft.AspNet.Mvc.TagHelpers.ScriptTagHelper}
protected ILogger<ScriptTagHelper> Logger { get; }
Order()
Return type:System.Int32
public override int Order { get; }
Src()

Address of the external script to use.

Return type:System.String
public string Src { get; set; }
SrcExclude()

A comma separated list of globbed file patterns of JavaScript scripts to exclude from loading. The glob patterns are assessed relative to the application’s ‘webroot’ setting. Must be used in conjunction with Microsoft.AspNet.Mvc.TagHelpers.ScriptTagHelper.SrcInclude.

Return type:System.String
public string SrcExclude { get; set; }
SrcInclude()

A comma separated list of globbed file patterns of JavaScript scripts to load. The glob patterns are assessed relative to the application’s ‘webroot’ setting.

Return type:System.String
public string SrcInclude { get; set; }
ViewContext()
Return type:Microsoft.AspNet.Mvc.Rendering.ViewContext
public ViewContext ViewContext { get; set; }