Commit Diff


commit - d11bc342aae0489afa874fef2e05e07a9912b36b
commit + 1560af799348ecbf7e9e8d27838254dd3df43fbc
blob - fba6dd55e1ff1b47f978109d3df833349c0554a1
blob + 8d00dd266fc4970b94aee4cc71061253377837bc
--- README.md
+++ README.md
@@ -33,10 +33,12 @@ external_rel
 
 ## Partials
 
-### element
-Создаёт HTML элемент, с именем тэга = .tag, атрибутами = .attributes, содержимым .inner.
+### attrs
+Рендерит словарь из ключей и значений в виде атрибутов тэга.
+Для булевых значений вставляется или не вставляется соответствующий ключ без значения.
 
-Если тэг не установлен, то проставляется значение по умолчанию `tag`.
+### pick
+Отбирает из dict ключи, входящие в массив allowed.
 
 ### image
 Отображает изображение, передаваемое в .image.
blob - 8bf7544ea842d8d60b4a9e152a64caeb31cae32f (mode 644)
blob + /dev/null
--- layouts/_partials/element.html
+++ /dev/null
@@ -1,9 +0,0 @@
-{{- $tag := default "div" .tag -}}
-
-{{- printf "<%s" $tag | safeHTML -}}
-{{- partial "attrs.html" (.attributes | default dict) -}}
-{{- printf ">" | safeHTML -}}
-
-{{- default "" .inner | safeHTML -}}
-
-{{- printf "</%s>" $tag | safeHTML -}}
blob - /dev/null
blob + 2a912f83e3e9302352879a8a2a8e2ac00a95e5e4 (mode 644)
--- /dev/null
+++ layouts/_partials/pick.html
@@ -0,0 +1,9 @@
+{{- $result := dict -}}
+
+{{- range .allowed -}}
+  {{- if isset $.dict . -}}
+    {{- $result = merge $result (dict . (index $.dict .)) -}}
+  {{- end -}}
+{{- end -}}
+
+{{- return $result -}}
blob - d86a9de4d9c5c2249548045a7c4a57f69698bbd7
blob + 7f3b64a0ef18c2199acece85168cc9c359c58533
--- layouts/_shortcodes/a.html
+++ layouts/_shortcodes/a.html
@@ -15,17 +15,11 @@
   "aria-current"
   "aria-describedby"
 -}}
-
-{{- $attributes := dict -}}
-
-{{- range $name, $value := .Params -}}
-  {{- if in $allowed $name -}}
-    {{- $attributes = merge $attributes (dict $name $value) -}}
-  {{- end -}}
-{{- end -}}
-
-{{- partial "element.html" (dict
-  "tag" "a"
-  "inner" .Inner
-  "attributes" $attributes
+{{- $attributes := partial "pick.html" (dict
+  "dict" .Params
+  "allowed" $allowed
 ) -}}
+
+<a{{ partial "attrs.html" $attributes }}>
+  {{ .Inner }}
+</a>
blob - dd3e8886fe002d9caec6cf88aef7d7a79f1ba9fa
blob + 1fbc779b37e04de07d90167dc50c7b2a5ba6aede
--- layouts/_shortcodes/section.html
+++ layouts/_shortcodes/section.html
@@ -1,14 +1,9 @@
 {{- $allowed := slice "class" "id" -}}
-{{- $attributes := dict -}}
-
-{{- range $name, $value := .Params -}}
-  {{- if in $allowed $name -}}
-    {{- $attributes = merge $attributes (dict $name $value) -}}
-  {{- end -}}
-{{- end -}}
-
-{{- partial "element.html" (dict
-  "tag" "section"
-  "inner" .Inner
-  "attributes" $attributes
+{{- $attributes := partial "pick.html" (dict
+  "dict" .Params
+  "allowed" $allowed
 ) -}}
+
+<section{{ partial "attrs.html" $attributes }}>
+  {{ .Inner }}
+</section>