Table of Contents

Class AppScriptTagHelper

Namespace
Cuemon.AspNetCore.Razor.TagHelpers
Assembly
Cuemon.AspNetCore.Razor.TagHelpers.dll

Provides an implementation targeting <script> elements that supports ICacheBusting versioning of a static script placed on a location outside (but tied to) your application. This class cannot be inherited.

[HtmlTargetElement("app-script")]
public sealed class AppScriptTagHelper : ScriptTagHelper<AppTagHelperOptions>, ITagHelper, ITagHelperComponent, IConfigurable<AppTagHelperOptions>
Inheritance
AppScriptTagHelper
Implements
Inherited Members

Examples

The following example demonstrates how to create with application-scoped options.

using System;
using System.Collections.Generic;
using Cuemon.AspNetCore.Razor.TagHelpers;
using Microsoft.Extensions.Options;

namespace MyApp.Examples;

public static class AppScriptTagHelperExample
{
    public static void Demonstrate()
    {
        var options = Options.Create(new AppTagHelperOptions
        {
            Scheme = ProtocolUriScheme.Relative,
            BaseUrl = "static.cuemon.net"
        });

        var tagHelper = new AppScriptTagHelper(options);
        var segments = new List<string>
        {
            options.Value.GetFormattedBaseUrl(),
            "js/app.js"
        };

        Console.WriteLine(string.Concat(segments));
        Console.WriteLine(tagHelper.GetType().Name);
    }
}

Constructors

AppScriptTagHelper(IOptions<AppTagHelperOptions>, ICacheBusting)

Initializes a new instance of the AppScriptTagHelper class.

public AppScriptTagHelper(IOptions<AppTagHelperOptions> setup, ICacheBusting cacheBusting = null)

Parameters

setup IOptions<AppTagHelperOptions>

The CdnTagHelperOptions which need to be configured.

cacheBusting ICacheBusting

An optional object implementing the ICacheBusting interface.

See Also

ScriptTagHelper<TOptions>