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

github.com/twbs/bootstrap.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXhmikosR <xhmikosr@gmail.com>2021-01-16 22:51:12 +0300
committerXhmikosR <xhmikosr@gmail.com>2021-08-31 17:24:38 +0300
commit5cc633dfabf3687bbbae9344725435031b022e81 (patch)
tree0214e560c65be3ffe261fb40baea3f25128126cd
parent9050b2698a9df1be49e3fe8c4e2f33c0a227cbf9 (diff)
Minor shortcode tweaks and consistency changes
-rw-r--r--site/layouts/shortcodes/bs-table.html3
-rw-r--r--site/layouts/shortcodes/callout.html3
-rw-r--r--site/layouts/shortcodes/example.html16
-rw-r--r--site/layouts/shortcodes/param.html4
-rw-r--r--site/layouts/shortcodes/placeholder.html27
-rw-r--r--site/layouts/shortcodes/table.html13
-rw-r--r--site/layouts/shortcodes/year.html4
7 files changed, 37 insertions, 33 deletions
diff --git a/site/layouts/shortcodes/bs-table.html b/site/layouts/shortcodes/bs-table.html
index 40b9b8ce56..42a18d5782 100644
--- a/site/layouts/shortcodes/bs-table.html
+++ b/site/layouts/shortcodes/bs-table.html
@@ -1,6 +1,5 @@
{{- /*
- Usage: `bs-table "class class-foo"`,
- where class can be anything
+ Usage: `bs-table "class class-foo"`, where class can be any string
*/ -}}
{{- $css_class := .Get 0 | default "table" -}}
diff --git a/site/layouts/shortcodes/callout.html b/site/layouts/shortcodes/callout.html
index 007f8a8e8e..86683ecf4c 100644
--- a/site/layouts/shortcodes/callout.html
+++ b/site/layouts/shortcodes/callout.html
@@ -1,6 +1,5 @@
{{- /*
- Usage: `callout "type"`,
- where type is one of info (default), danger, warning
+ Usage: `callout "type"`, where `type` is one of info (default), danger, or warning
*/ -}}
{{- $css_class := .Get 0 | default "info" -}}
diff --git a/site/layouts/shortcodes/example.html b/site/layouts/shortcodes/example.html
index fd20839cbe..65cd5a9f33 100644
--- a/site/layouts/shortcodes/example.html
+++ b/site/layouts/shortcodes/example.html
@@ -1,20 +1,22 @@
{{- /*
- Usage: `example [args]`
+ Usage: `example args`
- `args` are optional and can be one of the following:
- id: the `div`'s id - default: ""
- class: any extra class(es) to be added to the `div` - default ""
- show_preview: if the preview should be output in the HTML - default: `true`
- show_markup: if the markup should be output in the HTML - default: `true`
+ `args` are all optional and can be one of the following:
+ * id: the `div`'s id - default: ""
+ * class: any extra class(es) to be added to the `div` - default: ""
+ * show_preview: if the preview should be output in the HTML - default: `true`
+ * show_markup: if the markup should be output in the HTML - default: `true`
*/ -}}
+{{- $id := .Get "id" -}}
+{{- $class := .Get "class" -}}
{{- $lang := .Get "lang" | default "html" -}}
{{- $show_preview := .Get "show_preview" | default true -}}
{{- $show_markup := .Get "show_markup" | default true -}}
{{- $input := .Inner -}}
{{- if eq $show_preview true -}}
-<div{{ with .Get "id" }} id="{{ . }}"{{ end }} class="bd-example{{ with .Get "class" }} {{ . }}{{ end }}">
+<div{{ with $id }} id="{{ . }}"{{ end }} class="bd-example{{ with $class }} {{ . }}{{ end }}">
{{- $input -}}
</div>
{{- end -}}
diff --git a/site/layouts/shortcodes/param.html b/site/layouts/shortcodes/param.html
index 50e2060ae2..34ad00c87a 100644
--- a/site/layouts/shortcodes/param.html
+++ b/site/layouts/shortcodes/param.html
@@ -1,11 +1,13 @@
{{- /*
Work around wrong escapes in integrity attributes.
+ Original: https://github.com/gohugoio/hugo/blob/master/tpl/tplimpl/embedded/templates/shortcodes/param.html
*/ -}}
{{- $name := .Get 0 -}}
{{- with $name -}}
{{- $value := $.Page.Param . -}}
-{{- if in $name "_hash" -}}
+{{- /* If any parameter ends with `_hash`, mark the string as safe HTML */ -}}
+{{- if (strings.HasSuffix $name "_hash") -}}
{{- $value = $value | safeHTML -}}
{{- end -}}
{{- with $value }}{{ . }}{{ else }}{{ errorf "Param %q not found: %s" $name $.Position }}{{ end -}}
diff --git a/site/layouts/shortcodes/placeholder.html b/site/layouts/shortcodes/placeholder.html
index 2373bc9274..c267bf4a75 100644
--- a/site/layouts/shortcodes/placeholder.html
+++ b/site/layouts/shortcodes/placeholder.html
@@ -1,21 +1,24 @@
{{- /*
Usage: `placeholder args`
- args can be one of the following:
- title: Used in the SVG `title` tag, default "Placeholder"
- text: The text to show in the image - default: "width x height"
- class: default: "bd-placeholder-img"
- color: The text color (foreground) - default: "#dee2e6"
- background: The background color - default: "#868e96"
- width: default: 100%
- height: default: 180px
+ `args` are all optional and can be one of the following:
+ * title: Used in the SVG `title` tag - default: "Placeholder"
+ * text: The text to show in the image - default: "width x height"
+ * class: Class to add to the `svg` - default: "bd-placeholder-img"
+ * color: The text color (foreground) - default: "#dee2e6"
+ * background: The background color - default: "#868e96"
+ * width: default: "100%"
+ * height: default: "180px"
*/ -}}
{{- $grays := $.Site.Data.grays -}}
+{{- $default_color := (index $grays 2).hex -}}
+{{- $default_background := (index $grays 5).hex -}}
+
{{- $title := .Get "title" | default "Placeholder" -}}
{{- $class := .Get "class" -}}
-{{- $color := .Get "color" | default (index $grays 2).hex -}}
-{{- $background := .Get "background" | default (index $grays 5).hex -}}
+{{- $color := .Get "color" | default $default_color -}}
+{{- $background := .Get "background" | default $default_background -}}
{{- $width := .Get "width" | default "100%" -}}
{{- $height := .Get "height" | default "180" -}}
{{- $text := .Get "text" | default (printf "%sx%s" $width $height) -}}
@@ -24,7 +27,7 @@
{{- $show_text := not (eq $text "false") -}}
<svg class="bd-placeholder-img{{ with $class }} {{ . }}{{ end }}" width="{{ $width }}" height="{{ $height }}" xmlns="http://www.w3.org/2000/svg"{{ if (or $show_title $show_text) }} role="img" aria-label="{{ if $show_title }}{{ $title }}{{ if $show_text }}: {{ end }}{{ end }}{{ if ($show_text) }}{{ $text }}{{ end }}"{{ else }} aria-hidden="true"{{ end }} preserveAspectRatio="xMidYMid slice" focusable="false">
- {{- if $show_title -}}<title>{{ $title }}</title>{{- end -}}
+ {{- if $show_title }}<title>{{ $title }}</title>{{ end -}}
<rect width="100%" height="100%" fill="{{ $background }}"/>
- {{- if $show_text -}}<text x="50%" y="50%" fill="{{ $color }}" dy=".3em">{{ $text }}</text>{{- end -}}
+ {{- if $show_text }}<text x="50%" y="50%" fill="{{ $color }}" dy=".3em">{{ $text }}</text>{{ end -}}
</svg>
diff --git a/site/layouts/shortcodes/table.html b/site/layouts/shortcodes/table.html
index 43f230ab84..a98b5eb899 100644
--- a/site/layouts/shortcodes/table.html
+++ b/site/layouts/shortcodes/table.html
@@ -2,27 +2,28 @@
Usage: `table [args]`
`args` are optional and can be one of the following:
- class: any class(es) to be added to the `table` - default ""
- simplified: show a simplified version in the examples - default `true`
+ * class: any class(es) to be added to the `table` - default ""
+ * simplified: show a simplified version in the examples - default `true`
*/ -}}
+{{- $class := .Get "class" -}}
{{- $simplified := .Get "simplified" | default true -}}
{{- $table_attributes := "" -}}
{{- $table_content := " ...\n" -}}
-{{- with .Get "class" -}}
-{{- $table_attributes = printf ` class="%s"` . -}}
+{{- with $class -}}
+ {{- $table_attributes = printf ` class="%s"` . -}}
{{- end -}}
{{- if eq $simplified "false" -}}
-{{- $table_content = partialCached "table-content" . -}}
+ {{- $table_content = partialCached "table-content" . -}}
{{- end -}}
{{- $table := printf "<table%s>\n%s</table>" $table_attributes $table_content -}}
<div class="bd-example">
- <table{{ with .Get "class" }} class="{{ . }}"{{ end }}>
+ <table{{ with $class }} class="{{ . }}"{{ end }}>
{{ partialCached "table-content" . }}
</table>
</div>
diff --git a/site/layouts/shortcodes/year.html b/site/layouts/shortcodes/year.html
index bc9dd300d1..db7f18e3fc 100644
--- a/site/layouts/shortcodes/year.html
+++ b/site/layouts/shortcodes/year.html
@@ -1,5 +1,3 @@
-{{- /*
- Output the current year
-*/ -}}
+{{- /* Outputs the current year */ -}}
{{- now.Format "2006" -}}