Skip to content
Permalink
Browse files
Add HTML attribute "id" to Button element
  • Loading branch information
jhauraw committed Jul 16, 2020
1 parent 7fb077f commit 6a1a598a2f4c66575e13cdb7af68cd26072256fe
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
@@ -3,8 +3,9 @@
{{- end }}
{{- $text := .text -}}
{{- $type := .type | default "default" -}}
{{- $svg := "" -}}
{{- $id := .id -}}
{{- $class := "" -}}
{{- $svg := "" -}}
{{- with .icon }}
{{- $svg = printf "svg/%s.svg" . -}}
{{- $svg = partial $svg (dict "class" "fill-current h-4 w-auto mr-2") -}}
@@ -23,7 +24,7 @@
{{- $class = printf "%s rounded font-content-sans font-semibold %s %s %s py-2 px-4 %s" $class $textColor $bgColor $hoverColor $borderColor -}}
{{- $class = trim $class " " -}}
{{- if $href }}
<a class="{{ $class }}" href="{{ $href }}" role="button">
<a{{ with $id }} id="{{ . }}"{{ end }} class="{{ $class }}" href="{{ $href }}" role="button">
{{- with $svg }}
{{ . | safeHTML }}
{{- end }}
@@ -2,18 +2,21 @@
{{- $type := "" -}}
{{- $icon := "" -}}
{{- $href := "" -}}
{{- $id := "" -}}
{{- if .IsNamedParams }}
{{- $text = .Get "text" -}}
{{- $type = .Get "type" -}}
{{- $icon = .Get "icon" -}}
{{- $href = .Get "href" -}}
{{- $id = .Get "id" -}}
{{- else }}
{{- $text = .Get 0 -}}
{{- $type = .Get 1 -}}
{{- $icon = .Get 2 -}}
{{- $href = .Get 3 -}}
{{- $id = .Get 4 -}}
{{- end }}
{{- if not $text }}
{{- errorf "Missing required 'text'. Shortcode: 'button'." -}}
{{- end }}
{{- partial "button" (dict "Site" $.Site "Page" . "text" $text "type" $type "icon" $icon "href" $href) -}}
{{- partial "button" (dict "Site" $.Site "Page" . "text" $text "type" $type "icon" $icon "href" $href "id" $id) -}}

0 comments on commit 6a1a598

Please sign in to comment.