RazorDocs Search
API Reference

TagHelpers

Type

AutoAssetVersioningTagHelper

Source

A TagHelper that automatically applies version hashing to script and link tags that reference local files, if the asp-append-version attribute is missing.

Method

IsLocal

bool IsLocal(string? path) Source

Determines if the provided path is a local path suitable for versioning.

Parameters

  • pathThe path to check.

Returns

true if the path is local (starts with '/' or '~') and is not protocol-relative; otherwise, false.

Remarks

Relative paths (e.g. "css/site.css") are excluded because they are ambiguous without knowing the current request path context, which complicates server-side resolution. Use root-relative ('/') or app-relative ('~') paths for automatic versioning.

Property

ViewContext

ViewContext ViewContext { get; set; } Source

Gets or sets the view context.

Remarks

This property is automatically set by the framework when the TagHelper is created.

Type

StreamSourceTagHelper

Source

Tag helper that renders an rw-stream-source element to establish a connection to a RazorWire stream.

Method

Process

void Process(TagHelperContext context, TagHelperOutput output) Source

Configures the rw-stream-source element by setting its src attribute and handling the permanent option.

Parameters

  • contextContains information associated with the current HTML tag.
  • outputA stateful HTML element used to generate an HTML tag.

Exceptions

  • InvalidOperationExceptionThrown when Channel is null, empty, or contains only whitespace.
Property

Channel

string Channel { get; set; } Source

Gets or sets the channel name of the stream to connect to. This attribute is required.

Property

Permanent

bool Permanent { get; set; } Source

Gets or sets a value indicating whether the stream source should be preserved across Turbo page loads.

Type

RequiresStreamTagHelper

Source

A TagHelper that marks an element as requiring a specific Turbo Stream to be established before becoming active.

Method

Process

void Process(TagHelperContext context, TagHelperOutput output) Source

Applies stream-requirement attributes and disables the element when a requires-stream value is present.

Remarks

If RequiresStream is null or whitespace, the output is left unchanged. Otherwise adds the following attributes to the element:
  • data-rw-requires-stream set to the RequiresStream value
  • aria-disabled to "true"
  • disabled to "disabled" (only for supported form elements)
The element is therefore disabled until client-side code removes or updates these attributes.
Property

RequiresStream

string? RequiresStream { get; set; } Source

Gets or sets the name or identifier of the stream required by this element.

Type

RazorWireFormTagHelper

Source

A Tag Helper that enhances a standard <form> element with RazorWire/Turbo features.

Method

Process

void Process(TagHelperContext context, TagHelperOutput output) Source

Processes a form tag by removing attributes that start with "rw-" and configuring Turbo attributes based on the tag helper's properties.

Parameters

  • contextThe context for the current tag helper execution.
  • outputThe tag helper output whose attributes will be modified.
Property

Enabled

bool Enabled { get; set; } Source

Gets or sets a value indicating whether RazorWire/Turbo enhancement is enabled for this form. Defaults to true.

Property

TargetFrame

string? TargetFrame { get; set; } Source

Gets or sets the identifier of the Turbo Frame that this form should target.

Type

RazorWireScriptsTagHelper

Source

Tag helper for rendering the necessary RazorWire scripts.

Method

Process

void Process(TagHelperContext context, TagHelperOutput output) Source

Renders the client-side script tags required by RazorWire and removes the wrapper element so no enclosing tag is emitted.

Parameters

  • contextThe current tag helper context.
  • outputThe tag helper output that will be modified to contain the script elements and have no wrapper tag.
Property

ViewContext

ViewContext ViewContext { get; set; } Source

Gets or sets the view context.

Type

IslandTagHelper

Source

A TagHelper that renders a Turbo Frame as a "RazorWire Island", enabling partial page updates and client-side module mounting.

Method

Process

void Process(TagHelperContext context, TagHelperOutput output) Source

Renders a <turbo-frame> element whose attributes are populated from the tag helper's properties.

Exceptions

  • ArgumentExceptionThrown when Id is null, empty, or consists only of white-space characters.

Remarks

Validates that Id is not null, empty, or whitespace and sets attributes such as id, src, loading, data-turbo-permanent, data-rw-swr, style (view-transition-name), data-rw-export, and client-related data attributes when the corresponding properties are provided.

Property

Id

string Id { get; set; } Source

The unique identifier for the island, which becomes the id of the rendered turbo-frame.

Property

Src

string? Src { get; set; } Source

The source URL for the turbo-frame content.

Property

Loading

string? Loading { get; set; } Source

The loading strategy for the turbo-frame (e.g., "eager", "lazy").

Property

Permanent

bool Permanent { get; set; } Source

If true, the rendered element will have the 'data-turbo-permanent' attribute.

Property

Swr

bool Swr { get; set; } Source

If true, enables Stale-While-Revalidate behavior via 'data-rw-swr'.

Property

TransitionName

string? TransitionName { get; set; } Source

The name for the CSS View Transition, applied as 'view-transition-name' in the style attribute.

Property

Export

string? Export { get; set; } Source

The name of the client-side module to export/expose.

Property

ClientModule

string? ClientModule { get; set; } Source

The path to the client-side module to mount on this island.

Property

ClientStrategy

string? ClientStrategy { get; set; } Source

The mounting strategy for the client module (e.g., "load", "visible", "idle").

Property

ClientProps

string? ClientProps { get; set; } Source

Initial properties (JSON) to pass to the client module's mount function.

Type

LocalTimeTagHelper

Source

Tag helper that renders a <time> element with a UTC timestamp for client-side time formatting.

Remarks

When rw-type="local", the JavaScript runtime formats the timestamp to the user's local timezone. When rw-type="utc", the timestamp is formatted in UTC.

Example

<time rw-type="local" datetime="@Model.Timestamp"></time>
 <time rw-type="local" datetime="@Model.Timestamp" rw-display="relative"></time>
 <time rw-type="local" datetime="@Model.Timestamp" rw-display="datetime" rw-format="short"></time>
 <time rw-type="utc" datetime="@Model.Timestamp"></time>
Method

Process

void Process(TagHelperContext context, TagHelperOutput output) Source

Renders a <time> element with the UTC timestamp in the datetime attribute and data attributes for client-side JavaScript formatting.

Parameters

  • contextContains information associated with the current HTML tag.
  • outputA stateful HTML element used to generate an HTML tag.

Exceptions

  • ArgumentExceptionThrown when Value is the default value or if Display or Format have invalid values.
Property

RwType

string? RwType { get; set; } Source

Gets or sets the timezone type for RazorWire time formatting. Valid values: local (user's browser timezone) or utc (UTC timezone).

Property

Value

DateTimeOffset Value { get; set; } Source

The UTC timestamp to display, sourced from the datetime attribute.

Property

Display

string Display { get; set; } Source

Gets or sets the display mode for the formatted time. Valid values: time (default), date, datetime, or relative.

Property

Format

string? Format { get; set; } Source

Gets or sets the format style for absolute time formatting. Valid values: short, medium (default), long, or full.