diff --git a/source/_patterns/00-atoms/_attributes.twig b/source/_patterns/00-atoms/_attributes.twig deleted file mode 100644 index b673abfb..00000000 --- a/source/_patterns/00-atoms/_attributes.twig +++ /dev/null @@ -1,11 +0,0 @@ -{%- for name, value in attributes|default({}) if value is not same as(false) -%} - - {{- ' ' ~ name -}} - - {%- if value is iterable -%} - ="{{ value|join(' ') }}" - {%- elseif value is not same as(true) -%} - ="{{ value }}" - {%- endif -%} - -{%- endfor -%} diff --git a/source/_patterns/00-atoms/_html.twig b/source/_patterns/00-atoms/_html.twig new file mode 100644 index 00000000..0bd85aa9 --- /dev/null +++ b/source/_patterns/00-atoms/_html.twig @@ -0,0 +1,37 @@ +{%- macro content(content) -%} + + {%- import _self as html -%} + + {%- if content.template is defined -%} + + {%- include content.template with content.arguments|default({}) only -%} + + {%- elseif content is iterable -%} + + {%- for node in content -%} + {{- html.content(node) -}} + {%- endfor -%} + + {%- else -%} + + {{- content -}} + + {%- endif -%} + +{%- endmacro content -%} + +{%- macro attributes(attributes) -%} + + {%- for name, value in attributes|default({}) if value is not same as(false) -%} + + {{- ' ' ~ name -}} + + {%- if value is iterable -%} + ="{{ value|join(' ') }}" + {%- elseif value is not same as(true) -%} + ="{{ value }}" + {%- endif -%} + + {%- endfor -%} + +{%- endmacro attributes -%} diff --git a/source/_patterns/00-atoms/_text.twig b/source/_patterns/00-atoms/_text.twig deleted file mode 100644 index c87ac139..00000000 --- a/source/_patterns/00-atoms/_text.twig +++ /dev/null @@ -1,17 +0,0 @@ -{%- if nodes is iterable -%} - - {%- for node in nodes -%} - - {%- if node.template is defined -%} - {%- include node.template with node.arguments only -%} - {%- else -%} - {{- node -}} - {%- endif -%} - - {%- endfor -%} - -{%- else -%} - - {{- nodes -}} - -{%- endif -%} diff --git a/source/_patterns/00-atoms/block/heading/heading.twig b/source/_patterns/00-atoms/block/heading/heading.twig index 9866ed66..a0e188cd 100644 --- a/source/_patterns/00-atoms/block/heading/heading.twig +++ b/source/_patterns/00-atoms/block/heading/heading.twig @@ -1,6 +1,8 @@ +{%- import 'atoms-html' as html -%} + {%- set attributes = attributes|default({})|merge({class: attributes.class|default([])|merge(['heading']) }) -%} - + {%- if text.text is not defined -%} {%- set text = {text: text} -%} diff --git a/source/_patterns/00-atoms/block/paragraph/paragraph.twig b/source/_patterns/00-atoms/block/paragraph/paragraph.twig index f70acfba..86799482 100644 --- a/source/_patterns/00-atoms/block/paragraph/paragraph.twig +++ b/source/_patterns/00-atoms/block/paragraph/paragraph.twig @@ -1,7 +1,9 @@ +{%- import 'atoms-html' as html -%} + {%- set attributes = attributes|default({})|merge({class: attributes.class|default([])|merge(['paragraph']) }) -%} -

+

- {%- include 'atoms-text' with {nodes: text} -%} + {{- html.content(text) -}}

diff --git a/source/_patterns/00-atoms/inline/bold/bold.twig b/source/_patterns/00-atoms/inline/bold/bold.twig index f6d6bec1..fa81a533 100644 --- a/source/_patterns/00-atoms/inline/bold/bold.twig +++ b/source/_patterns/00-atoms/inline/bold/bold.twig @@ -1,8 +1,10 @@ +{%- import 'atoms-html' as html -%} + {% spaceless %} - + - {%- include 'atoms-text' with {nodes: text} only -%} + {{- html.content(text) -}} diff --git a/source/_patterns/00-atoms/inline/italic/italic.twig b/source/_patterns/00-atoms/inline/italic/italic.twig index 64416ecd..6efc7b02 100644 --- a/source/_patterns/00-atoms/inline/italic/italic.twig +++ b/source/_patterns/00-atoms/inline/italic/italic.twig @@ -1,8 +1,10 @@ +{%- import 'atoms-html' as html -%} + {% spaceless %} - + - {%- include 'atoms-text' with {nodes: text} only -%} + {{- html.content(text) -}} diff --git a/source/_patterns/00-atoms/inline/link/link.twig b/source/_patterns/00-atoms/inline/link/link.twig index aa203e67..5c0c22e1 100644 --- a/source/_patterns/00-atoms/inline/link/link.twig +++ b/source/_patterns/00-atoms/inline/link/link.twig @@ -1,11 +1,13 @@ +{%- import 'atoms-html' as html -%} + {% spaceless %} {%- if attributes|default({}).href is defined -%} - {%- include 'atoms-text' with {nodes: text} only -%} + {{- html.content(text) -}} {%- elseif attributes|default({})|length -%} - {%- include 'atoms-text' with {nodes: text} only -%} + {{- html.content(text) -}} {%- else -%} - {%- include 'atoms-text' with {nodes: text} only -%} + {{- html.content(text) -}} {%- endif -%} {% endspaceless %} diff --git a/source/_patterns/00-atoms/inline/sub/sub.twig b/source/_patterns/00-atoms/inline/sub/sub.twig index ed64afa3..903ba097 100644 --- a/source/_patterns/00-atoms/inline/sub/sub.twig +++ b/source/_patterns/00-atoms/inline/sub/sub.twig @@ -1,8 +1,10 @@ +{%- import 'atoms-html' as html -%} + {% spaceless %} - + - {%- include 'atoms-text' with {nodes: text} only -%} + {{- html.content(text) -}} diff --git a/source/_patterns/00-atoms/inline/sup/sup.twig b/source/_patterns/00-atoms/inline/sup/sup.twig index 227c6dfa..1b3fcfd0 100644 --- a/source/_patterns/00-atoms/inline/sup/sup.twig +++ b/source/_patterns/00-atoms/inline/sup/sup.twig @@ -1,8 +1,10 @@ +{%- import 'atoms-html' as html -%} + {% spaceless %} - + - {%- include 'atoms-text' with {nodes: text} only -%} + {{- html.content(text) -}} diff --git a/source/_patterns/00-atoms/inline/time/time.twig b/source/_patterns/00-atoms/inline/time/time.twig index b2684243..8be890a9 100644 --- a/source/_patterns/00-atoms/inline/time/time.twig +++ b/source/_patterns/00-atoms/inline/time/time.twig @@ -1,8 +1,10 @@ +{%- import 'atoms-html' as html -%} + {% spaceless %} -