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
antiforgeryIAntiforgeryThe service used to generate antiforgery tokens.
optionsIOptions<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
Methods
ProcessAsync(TagHelperContext, TagHelperOutput)
Asynchronously executes the TagHelper with the given context and
output.
public override Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
Parameters
contextTagHelperContextContains information associated with the current HTML tag.
outputTagHelperOutputA stateful HTML element used to generate an HTML tag.
Returns
Remarks
By default this calls into Process(TagHelperContext, TagHelperOutput).