The type shortcode displays data types, expressions, and value sets with differentiated styles.

Basic usage #

Provide the type as a positional parameter:

{{< type string >}}
{{< type number >}}
{{< type boolean >}}

Result #

string number boolean

Parameters #

ParameterPositionTypeRequiredDescription
name0stringYesType, expression, or value set to be displayed.

The parameter can also be provided as type:

{{< type name="string" >}}
{{< type type="number" >}}

Recognized types #

The shortcode classifies certain type names to apply specific styles to them. Comparison is case-insensitive.

CategoryRecognized types
textualstring, char, rune, byte
numericnumber, int, float, uint
logicalboolean, bool
structuralobject, array, function, map, set

For example:

{{< type string >}}
{{< type int >}}
{{< type bool >}}
{{< type object >}}

Result #

string int bool object

Custom types #

Types that do not match any recognized values are classified as custom and displayed without modifying their content:

{{< type "UserConfig" >}}
{{< type "Promise<Response>" >}}
{{< type "string | null" >}}
{{< type "string[]" >}}

Result #

UserConfig Promise<Response> string | null string[]

The shortcode does not parse expression syntax. The received value is displayed as text.

Optional types #

Append ? to the end of the type to indicate that it is optional:

{{< type "string?" >}}
{{< type "number?" >}}
{{< type "UserConfig?" >}}

Result #

string number UserConfig

Allowed values #

Wrap a set of values between { and } to classify them as values:

{{< type "{light | dark}" >}}
{{< type "{asc | desc}" >}}
{{< type "{fixed | fluid}" >}}

Result #

lightdark ascdesc fixedfluid

Positional syntax #

The type name can be provided as the first positional parameter:

{{< type string >}}
{{< type "Promise<Response>" >}}
{{< type "{light | dark}" >}}

The name parameter can also be used via named parameters:

{{< type name="string" >}}
{{< type type="number" >}}