commit - 1560af799348ecbf7e9e8d27838254dd3df43fbc
commit + 5a365c2607655acb416397319c5c362e1bbb4f15
blob - 3ba203f999fae7f8dffd8690bd5c2cbbabe9a00f
blob + 0c2c104a94a01d3ca17d2ad2e9742783997e256b
--- layouts/_shortcodes/source.html
+++ layouts/_shortcodes/source.html
{{- end -}}
{{- end -}}
-{{- $codecs := .Get "codecs" -}}
-{{- if and $type $codecs -}}
- {{- $type = printf "%s; codecs=%s" $type $codecs -}}
-{{- end -}}
-
-{{- $allowed := slice
- "srcset"
- "sizes"
- "media"
- "width"
- "height"
--}}
-
-{{- $attributes := dict "src" $src -}}
-
-{{- range $name, $value := .Params -}}
- {{- if in $allowed $name -}}
- {{- $attributes = merge $attributes (dict $name $value) -}}
+{{- with .Get "codecs" -}}
+ {{- if $type -}}
+ {{- $type = printf "%s; codecs=%s" $type . -}}
{{- end -}}
{{- end -}}
-{{- with $type -}}
- {{- $attributes = merge $attributes (dict "type" .) -}}
-{{- end -}}
+{{- $attributes := partial "pick.html" (dict
+ "dict" .Params
+ "allowed" (slice "srcset" "sizes" "media" "width" "height")
+) -}}
+{{- $attributes = merge $attributes (dict
+ "src" $src
+ "type" $type
+) -}}
+
<source{{ partial "attrs.html" $attributes }}>
blob - 88fa63e3feb9a9939d2cd375aa2361ce9fe57e08
blob + 6a15da496d704cb08b9e79ddb78e1f1d7e8ab7a6
--- layouts/_shortcodes/video.html
+++ layouts/_shortcodes/video.html
"controls"
-}}
-{{- $attributes := dict
+{{- $defaults := dict
"autoplay" true
"loop" true
"muted" true
"controls" false
-}}
-{{- range $name, $value := .Params -}}
- {{- if in $allowed $name -}}
- {{- $attributes = merge $attributes (dict $name $value) -}}
- {{- end -}}
-{{- end -}}
+{{- $attributes := partial "pick.html" (dict
+ "dict" .Params
+ "allowed" $allowed
+) -}}
+{{- $attributes = merge $defaults $attributes -}}
+
<video{{ partial "attrs.html" $attributes }}>
{{ .Inner }}
</video>