-
Notifications
You must be signed in to change notification settings - Fork 12
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
Make placeholders case-insensitives for non-developers friendliness #46
Comments
Hi again 🙂 That's a good issue/question that I hadn't considered! What I see about the usage of google-docs-mustaches, is that it allows non-developers to write google-docs template. Because of that, those type of users may not know the importance of the casing when using placeholders/formatters. (They may write So instead of throwing errors that they may not understand, I would prefer to allow any casing they prefer. What do you think? |
That's a very good point! Do you want to include that feature in your refactoring? |
I just pushed the first version of the refactoring here: #48. Don't hesitate to have a look and play with it. Having feedbacks would really help 🙂 I haven't included this feature in the refactoring. I think it can be a subsequent PR. If you feel up to it, you can definitely make the PR for this. Here is what I have in mind (but open to discussion): Casing (except in strings) should be insensitive in placeholders.
An idea would be to "lowercase everything", data and formatters alike, before using them. But we need to make sure to cover such case:
(The new parser allows for such complicated syntax. I guess the lowercasing could be done in the new parser too?) Anyway, that's just an idea. Feel free to propose a solution, or discuss it more here. 🙂 |
@Errorname Sounds good! I really like the idea of doing everything case insensitive and your first idea sounds good. I'll have a look on Sunday to play with your first version of refactoring and also see how to implement the case insensitivity |
The Issue
Hey, it's me again 😄
This ticket is about a small thing I noticed while working with the library and that is that formatter names are forced into lowercase.
I noticed it when I had a placeholder like
{{ name | getFirstname }}
and the corresponding formatter in codefunction getFirstname(name) {...}
When you then interpolate like this
it won't work. It'll throw you:
Error: getfirstname is not defined
in strict mode (note the the lowercasegetfirstname
when both the placeholder and the provided formatter are camel case.This is because of this line right here and I just don't quite get why the
.toLowerCase()
is needed heregoogle-docs-mustaches/src/documentProcessing/resolvePlaceholders/computeContent/pipe/pipe.ts
Lines 19 to 20 in 8f27905
I would just propose to remove the
.toLowerCase()
or why is it necessary there?The text was updated successfully, but these errors were encountered: