Skip to content

Commit 40e82e8

Browse files
[conditional-text] Avoid linebreaks when using the shortcode inline (google#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.
1 parent a917d9d commit 40e82e8

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed
+20-20
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,36 @@
11
<!-- Get the current buildcondition from the config and lowercase it -->
2-
{{ $condition := lower $.Site.Params.buildCondition }}
2+
{{- $condition := lower $.Site.Params.buildCondition -}}
33

4-
{{ if ne $condition "" }}
4+
{{- if ne $condition "" -}}
55

66
<!-- Get the parameters from the shortcode invocation and lowercase them.
77
TODO: to enable multiple conditions, we could accept comma-separated lists and split them -->
8-
{{ $include_if := lower (.Get "include-if") }}
9-
{{ $exclude_if := lower (.Get "exclude-if") }}
8+
{{- $include_if := lower (.Get "include-if") -}}
9+
{{- $exclude_if := lower (.Get "exclude-if") -}}
1010

11-
{{ if and (in $include_if $condition) (in $exclude_if $condition) }}
11+
{{- if and (in $include_if $condition) (in $exclude_if $condition) -}}
1212
<!-- condition appears in both parameters -->
1313
{{- errorf "Build condition %q appears in both include-if and exclude-if parameters of conditional-txt shortcode on page %s" $condition .Position -}}
14-
{{ end }}
14+
{{- end -}}
1515

16-
{{ if isset $.Params "include-if" }}
16+
{{- if isset $.Params "include-if" -}}
1717
<!-- WARNING substring matches are matches as well! That means, if include-if="foobar", and buildcondition is "foo", you have a match!-->
18-
{{ if in $include_if $condition }}
18+
{{- if in $include_if $condition -}}
1919
<!-- Do not indent the next Inner line, because the inner becomes a blockquote if the conditional-text is nested in another shortcode -->
20-
{{ .Inner }}
21-
{{ else }}
22-
{{ end }}
23-
{{ else }}
20+
{{- .Inner -}}
21+
{{- else -}}
22+
{{- end -}}
23+
{{- else -}}
2424

25-
{{ if isset $.Params "exclude-if" }}
25+
{{- if isset $.Params "exclude-if" -}}
2626
<!-- WARNING substring matches are matches as well! That means, if exclude-if="foobar", and buildcondition is "foo", you have a match!-->
27-
{{ if in $exclude_if $condition }}
28-
{{ else }}
27+
{{- if in $exclude_if $condition -}}
28+
{{- else -}}
2929
<!-- Do not indent the next Inner line, because the inner becomes a blockquote if the conditional-text is nested in another shortcode -->
30-
{{ .Inner }}
31-
{{ end }}
32-
{{ end }}
30+
{{- .Inner -}}
31+
{{- end -}}
32+
{{- end -}}
3333

34-
{{ end }}
34+
{{- end -}}
3535

36-
{{ end }}
36+
{{- end -}}

0 commit comments

Comments
 (0)