Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[conditional-text] Avoid linebreaks when using the shortcode inline #1220

Merged
merged 1 commit into from
Sep 5, 2022

Conversation

fekete-robert
Copy link
Collaborator

Until now, using the conditional-text shortcode inside a paragraph
caused linebreaks before and after the conditionally included text.
This patch fixes the issue.

Until now, using the conditional-text shortcode inside a paragraph
caused linebreaks before and after the conditionally included text.
This patch fixes the issue.
@LisaFC
Copy link
Collaborator

LisaFC commented Sep 5, 2022

This is great, thanks! Is there any chance any users have been depending on the line breaks (which I agree should not be there!), making this a breaking change? @geriom @chalin @emckean

@fekete-robert
Copy link
Collaborator Author

fekete-robert commented Sep 5, 2022 via email

@LisaFC
Copy link
Collaborator

LisaFC commented Sep 5, 2022

Good point! OK, I'm happy to merge this as agreed, the existing behaviour is not what I'd expect.

@LisaFC LisaFC merged commit 40e82e8 into google:main Sep 5, 2022
fekete-robert added a commit to fekete-robert/docsy that referenced this pull request Sep 13, 2022
…oogle#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,36 +1,36 @@
<!-- Get the current buildcondition from the config and lowercase it -->
{{ $condition := lower $.Site.Params.buildCondition }}
{{- $condition := lower $.Site.Params.buildCondition -}}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for cleaning up the whitespace issues in this shortcode @fekete-robert.

For next time, it is best to only add the - marker where it is needed. As a general rule of thumb, I favor the end tag -}}. More rarely do we need - on an opening tag, and certainly not in the case where two directives follow each other like this:

{{ if ... -}}
  {{ $var := val -}}
  {{ $var := val2 -}}
...

/cc @LisaFC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants