alexei/sprintf.js

Support Ruby syntax?

Opened this issue · 3 comments

Ruby has a slightly different syntax for named parameters in sprintf:

sprintf("This is a %{named}s parameter", { named: "beautiful" })

It uses %{...} rather than %(...) (which is already supported by sprintf.js).

@alexei Do you think the Ruby syntax could be added to sprintf.js? That would allow us moving code lines between frontend and backend more easily.

In case you approve adding it, I'd be happy to provide a pull request.

The re is rather cryptic so a test is warranted

@alexei Thank you for the feedback!

The re is rather cryptic so a test is warranted

Yes, I agree. 😄

I hope to work on this within the next two weeks but we are still discussing whether introducing sprintf.js as dependency is reasonable in https://gitlab.com/gitlab-org/gitlab-ce/issues/37992.

I see. Well, if you need %{num_users}, then poorManSprintf might be a better pick. See also #128