Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/negrel/hugo-theme-pico.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexandre Negrel <negrel.dev@protonmail.com>2021-01-26 23:26:54 +0300
committerAlexandre Negrel <negrel.dev@protonmail.com>2021-01-26 23:26:54 +0300
commit94ec43fe0ddc9c6ebc2eae14b59251c00d60e363 (patch)
treeda0da2dde7f231594ba82ecaf4b9cf36c4436526
parent8cdbcbb4883cc54f348fdd9dcdc7e9e927726e41 (diff)
adding button widget
-rw-r--r--layouts/partials/button.html16
1 files changed, 16 insertions, 0 deletions
diff --git a/layouts/partials/button.html b/layouts/partials/button.html
new file mode 100644
index 0000000..32b14b1
--- /dev/null
+++ b/layouts/partials/button.html
@@ -0,0 +1,16 @@
+{{ $el := "button" }}
+{{ if isset . "el" }}
+{{ $el = .el }}
+{{ end }}
+
+{{ $defaultClass := "px-4 py-2 mx-2 rounded-sm text-center"}}
+{{ $attrs := merge .attrs (dict "class" (printf "%s %s" $defaultClass .attrs.class)) }}
+
+{{ $btnAttrs := "" }}
+{{ range $attrName, $attrValue := $attrs }}
+{{ $btnAttrs = printf "%s %s='%s'" $btnAttrs $attrName $attrValue }}
+{{ end }}
+
+{{ safeHTML (printf "<%v %v>" $el $btnAttrs) }}
+ {{ .content }}
+{{ safeHTML (printf "</%v>" $el) }} \ No newline at end of file