Table of Contents

Class HtmxConfigTagHelper

Namespace
Ramstack.HtmxToolkit.TagHelpers
Assembly
Ramstack.HtmxToolkit.dll

Renders the application-wide HTMX configuration as a <meta> element.

[HtmlTargetElement("meta", Attributes = "htmx-config", TagStructure = TagStructure.WithoutEndTag)]
[HtmlTargetElement("htmx-config", TagStructure = TagStructure.NormalOrSelfClosing)]
public sealed class HtmxConfigTagHelper : TagHelper, ITagHelper, ITagHelperComponent
Inheritance
HtmxConfigTagHelper
Implements
Inherited Members

Examples

@addTagHelper *, Ramstack.HtmxToolkit

<head>
    <htmx-config />
</head>

@* Renders the settings selected in AddHtmxToolkit and the antiforgery token
   that the Toolkit script adds to HTMX requests:
   <meta name="htmx-config" content='{"timeout":10000}'
         data-antiforgery-request-token="..." ... /> *@

Constructors

HtmxConfigTagHelper(IAntiforgery, IOptions<HtmxToolkitOptions>)

Renders the application-wide HTMX configuration as a <meta> element.

public HtmxConfigTagHelper(IAntiforgery antiforgery, IOptions<HtmxToolkitOptions> options)

Parameters

antiforgery IAntiforgery

The service used to generate antiforgery tokens.

options IOptions<HtmxToolkitOptions>

The configured HTMX Toolkit options.

Properties

ViewContext

Gets or sets the view context for the current request.

[ViewContext]
[HtmlAttributeNotBound]
public ViewContext ViewContext { get; set; }

Property Value

ViewContext

Methods

ProcessAsync(TagHelperContext, TagHelperOutput)

Asynchronously executes the TagHelper with the given context and output.

public override Task ProcessAsync(TagHelperContext context, TagHelperOutput output)

Parameters

context TagHelperContext

Contains information associated with the current HTML tag.

output TagHelperOutput

A stateful HTML element used to generate an HTML tag.

Returns

Task

A Task that on completion updates the output.

Remarks

By default this calls into Process(TagHelperContext, TagHelperOutput).