mirror of
https://github.com/gethinode/hinode.git
synced 2025-10-14 05:23:15 +00:00
23 lines
1.0 KiB
HTML
23 lines
1.0 KiB
HTML
<!--
|
|
Highlights text by applying a background color. The shortcode supports the following arguments:
|
|
"color": Optional theme color of the highlight, either "primary", "secondary", "success", "danger",
|
|
"warning", "info", "light", "dark", "white" or "black". By default, the highlight uses the color of
|
|
the HTML mark function.
|
|
"class": Optional class attribute of the highlight element.
|
|
-->
|
|
|
|
{{- $error := false -}}
|
|
{{ $color := .Get "color" | default "" -}}
|
|
{{ $supportedColors := slice "primary" "secondary" "success" "danger" "warning" "info" "light" "dark" -}}
|
|
{{ if and $color (not (in $supportedColors $color)) -}}
|
|
{{ errorf "Invalid value for param 'color': %s" .Position -}}
|
|
{{ $error = true -}}
|
|
{{ end -}}
|
|
|
|
{{- $class := .Get "class" | default "" -}}
|
|
|
|
{{- if $color }}{{ $class = printf "%s text-bg-%s" $class $color }}{{ end -}}
|
|
|
|
{{- if not $error -}}
|
|
<mark{{ with $class }} class="{{ . }}"{{ end }}>{{ trim .Inner " \r\n" | .Page.RenderString -}}</mark>
|
|
{{- end -}} |