diff options
author | Robert Fekete <fekete77.robert@gmail.com> | 2022-09-05 17:20:48 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-05 17:20:48 +0300 |
commit | 40e82e877455cd236c7b91c4fd9fcd542550f796 (patch) | |
tree | 9492c13a776e0c4e10b986dc399e7f88a4c15681 | |
parent | a917d9da42c496054f5a9450f7c0def6a1d35ec8 (diff) |
[conditional-text] Avoid linebreaks when using the shortcode inline (#1220)
Until now, using the conditional-text shortcode inside a paragraph
caused linebreaks before and after the conditionally included text.
This patch fixes the issue.
-rw-r--r-- | layouts/shortcodes/conditional-text.html | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/layouts/shortcodes/conditional-text.html b/layouts/shortcodes/conditional-text.html index a343b49..ee7b230 100644 --- a/layouts/shortcodes/conditional-text.html +++ b/layouts/shortcodes/conditional-text.html @@ -1,36 +1,36 @@ <!-- Get the current buildcondition from the config and lowercase it --> -{{ $condition := lower $.Site.Params.buildCondition }} +{{- $condition := lower $.Site.Params.buildCondition -}} -{{ if ne $condition "" }} +{{- if ne $condition "" -}} <!-- Get the parameters from the shortcode invocation and lowercase them. TODO: to enable multiple conditions, we could accept comma-separated lists and split them --> - {{ $include_if := lower (.Get "include-if") }} - {{ $exclude_if := lower (.Get "exclude-if") }} + {{- $include_if := lower (.Get "include-if") -}} + {{- $exclude_if := lower (.Get "exclude-if") -}} - {{ if and (in $include_if $condition) (in $exclude_if $condition) }} + {{- if and (in $include_if $condition) (in $exclude_if $condition) -}} <!-- condition appears in both parameters --> {{- errorf "Build condition %q appears in both include-if and exclude-if parameters of conditional-txt shortcode on page %s" $condition .Position -}} - {{ end }} + {{- end -}} - {{ if isset $.Params "include-if" }} + {{- if isset $.Params "include-if" -}} <!-- WARNING substring matches are matches as well! That means, if include-if="foobar", and buildcondition is "foo", you have a match!--> - {{ if in $include_if $condition }} + {{- if in $include_if $condition -}} <!-- Do not indent the next Inner line, because the inner becomes a blockquote if the conditional-text is nested in another shortcode --> -{{ .Inner }} - {{ else }} - {{ end }} - {{ else }} +{{- .Inner -}} + {{- else -}} + {{- end -}} + {{- else -}} - {{ if isset $.Params "exclude-if" }} + {{- if isset $.Params "exclude-if" -}} <!-- WARNING substring matches are matches as well! That means, if exclude-if="foobar", and buildcondition is "foo", you have a match!--> - {{ if in $exclude_if $condition }} - {{ else }} + {{- if in $exclude_if $condition -}} + {{- else -}} <!-- Do not indent the next Inner line, because the inner becomes a blockquote if the conditional-text is nested in another shortcode --> -{{ .Inner }} - {{ end }} - {{ end }} +{{- .Inner -}} + {{- end -}} + {{- end -}} - {{ end }} + {{- end -}} -{{ end }} +{{- end -}} |