From e04cb15ac2179155791c69401743d568ecdeb016 Mon Sep 17 00:00:00 2001 From: Robert Fekete Date: Mon, 5 Sep 2022 16:20:48 +0200 Subject: [PATCH] [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. --- layouts/shortcodes/conditional-text.html | 40 ++++++++++++------------ 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/layouts/shortcodes/conditional-text.html b/layouts/shortcodes/conditional-text.html index a343b495d1..ee7b2308e8 100644 --- a/layouts/shortcodes/conditional-text.html +++ b/layouts/shortcodes/conditional-text.html @@ -1,36 +1,36 @@ -{{ $condition := lower $.Site.Params.buildCondition }} +{{- $condition := lower $.Site.Params.buildCondition -}} -{{ if ne $condition "" }} +{{- if ne $condition "" -}} - {{ $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) -}} {{- 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" -}} - {{ if in $include_if $condition }} + {{- if in $include_if $condition -}} -{{ .Inner }} - {{ else }} - {{ end }} - {{ else }} +{{- .Inner -}} + {{- else -}} + {{- end -}} + {{- else -}} - {{ if isset $.Params "exclude-if" }} + {{- if isset $.Params "exclude-if" -}} - {{ if in $exclude_if $condition }} - {{ else }} + {{- if in $exclude_if $condition -}} + {{- else -}} -{{ .Inner }} - {{ end }} - {{ end }} +{{- .Inner -}} + {{- end -}} + {{- end -}} - {{ end }} + {{- end -}} -{{ end }} +{{- end -}}