This repository was archived by the owner on Nov 21, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Use Twig macros rather than including templates #76
Merged
Merged
Changes from 1 commit
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
35a889e
Use Twig macros rather than including templates
thewilkybarkid 87c080d
Spacing fix
thewilkybarkid f82d270
Combine, and remove some redundant default filters
thewilkybarkid ca9ac9c
Add element macro
thewilkybarkid 176e1bf
Not needed
thewilkybarkid bfa3975
Trigger build
thewilkybarkid ab7b629
Whitespace
thewilkybarkid 5b9eaf7
Merge branch 'master' into macros
thewilkybarkid 3951d2a
Remove element
thewilkybarkid 2f348a0
Remove last of them, and try and reduce diff
thewilkybarkid 830f4bb
Not meant
thewilkybarkid File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,15 @@ | ||
| {%- for name, value in attributes|default({}) if value is not same as(false) -%} | ||
| {% macro attributes(attributes) %} | ||
|
|
||
| {{- ' ' ~ name -}} | ||
| {%- for name, value in attributes|default({}) if value is not same as(false) -%} | ||
|
|
||
| {%- if value is iterable -%} | ||
| ="{{ value|join(' ') }}" | ||
| {%- elseif value is not same as(true) -%} | ||
| ="{{ value }}" | ||
| {%- endif -%} | ||
| {{- ' ' ~ name -}} | ||
|
|
||
| {%- endfor -%} | ||
| {%- if value is iterable -%} | ||
| ="{{ value|join(' ') }}" | ||
| {%- elseif value is not same as(true) -%} | ||
| ="{{ value }}" | ||
| {%- endif -%} | ||
|
|
||
| {%- endfor -%} | ||
|
|
||
| {% endmacro attributes %} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| {% macro include(includes) %} | ||
|
|
||
| {%- if includes is iterable -%} | ||
|
|
||
| {%- for include in includes -%} | ||
|
|
||
| {%- if include.template is defined -%} | ||
| {%- include include.template with include.arguments|default({}) only -%} | ||
| {%- else -%} | ||
| {{- include -}} | ||
| {%- endif -%} | ||
|
|
||
| {%- endfor -%} | ||
|
|
||
| {%- else -%} | ||
|
|
||
| {{- includes -}} | ||
|
|
||
| {%- endif -%} | ||
|
|
||
| {% endmacro include %} |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,8 @@ | ||
| <h{{ level|default(1) }} {%- include 'atoms-attributes' %}> | ||
| {%- from 'atoms-attributes' import attributes -%} | ||
| {%- from 'atoms-includes' import include -%} | ||
|
|
||
| {%- include 'atoms-text' with {nodes: text} only -%} | ||
| <h{{ level|default(1) }} {{- attributes(attributes|default({})) }}> | ||
|
|
||
| {{- include(text) -}} | ||
|
|
||
| </h{{ level|default(1) }}> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,10 @@ | ||
| {%- from 'atoms-attributes' import attributes -%} | ||
| {%- from 'atoms-includes' import include -%} | ||
|
|
||
| {%- set attributes = attributes|default({})|merge({class: attributes.class|default([])|merge(['paragraph']) }) -%} | ||
|
|
||
| <p {%- include 'atoms-attributes' -%}> | ||
| <p {{- attributes(attributes) }}> | ||
|
|
||
| {%- include 'atoms-text' with {nodes: text} -%} | ||
| {{ include(text) }} | ||
|
|
||
| </p> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,14 @@ | ||
| {%- from 'atoms-attributes' import attributes -%} | ||
| {%- from 'atoms-includes' import include -%} | ||
|
|
||
| {% spaceless %} | ||
|
|
||
| {%- if attributes|default({}).href is defined -%} | ||
| <a {%- include 'atoms-attributes' %}>{%- include 'atoms-text' with {nodes: text} only -%}</a> | ||
| <a {{- attributes(attributes|default({})) }}>{{- include(text) -}}</a> | ||
| {%- elseif attributes|default({})|length -%} | ||
| <span {%- include 'atoms-attributes' %}>{%- include 'atoms-text' with {nodes: text} only -%}</span> | ||
| <span {{- attributes(attributes|default({})) }}>{{- include(text) -}}</span> | ||
| {%- else -%} | ||
| {%- include 'atoms-text' with {nodes: text} only -%} | ||
| {{- include(text) -}} | ||
| {%- endif -%} | ||
|
|
||
| {% endspaceless %} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
10 changes: 6 additions & 4 deletions
10
source/_patterns/01-molecules/content-meta/content-meta.twig
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 3 additions & 1 deletion
4
source/_patterns/02-organisms/content-header/content-header.twig
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Been going round the houses trying to find a way to improve this. Can't, and keep coming back to #40...