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

Incorrect docs for string interpolation #2004

Open
mjbcopland opened this issue Apr 22, 2021 · 2 comments
Open

Incorrect docs for string interpolation #2004

mjbcopland opened this issue Apr 22, 2021 · 2 comments
Labels
documentation Improvements or additions to documentation

Comments

@mjbcopland
Copy link
Contributor

mjbcopland commented Apr 22, 2021

String interpolation does not strip whitespace from values or modifiers. This isn't necessarily a bug but is not clarified anywhere and does mean that the docs are wrong.

Deriving a reproduction from transform-cache's cache key example which should interpolate the current date:

cacheKey: user-{args.id}-{yyyy-mm-dd | date}

We can see that the output is not as expected.

> stringInterpolator.parse("{yyyy-mm-dd | date}")
''

This is because there is whitespace in the modifier name which we can demonstrate by registering a modifier with that whitespace.

> stringInterpolator.registerModifier(" date", () => "Oops!")
Interpolator {}
> stringInterpolator.parse("{yyyy-mm-dd | date}"));
'Oops!'

The correct behaviour is to remove the whitespace from the interpolation template.

> stringInterpolator.parse("{yyyy-mm-dd|date}")
'2021-24-22'
@ardatan
Copy link
Owner

ardatan commented Apr 26, 2021

We'd love to accept a PR for this change :)

@ardatan ardatan added the documentation Improvements or additions to documentation label Apr 26, 2021
@Urigo
Copy link
Collaborator

Urigo commented Apr 26, 2021

At the bottom of each page there should be an "Edit this page" button so get you into changing the docs!

image

@theguild-bot theguild-bot mentioned this issue Aug 11, 2022
@theguild-bot theguild-bot mentioned this issue Sep 28, 2023
This was referenced Apr 30, 2024
This was referenced May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

3 participants