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

Making expressions case insensitive #1302

Closed
priedthirdeye opened this issue Jan 26, 2017 · 4 comments · Fixed by renovatebot/renovate#194
Closed

Making expressions case insensitive #1302

priedthirdeye opened this issue Jan 26, 2017 · 4 comments · Fixed by renovatebot/renovate#194

Comments

@priedthirdeye
Copy link

I'd like to make it so expressions are not case sensitive.

For example, the following data:

var context = {title: "My New Post"};
var html    = template(context);

would support both:

{{title}} 

and 

{{Title}}

I looked through the source code and can't see where I would make such a change. I understand there may be some performance impact, but this would really help for my use case.

@priedthirdeye
Copy link
Author

To be more clear....

I just want to get an idea of where in the source code I would make such a change.

@rafde
Copy link

rafde commented Jan 29, 2017

This doesn't sound ideal. It'll probably be easier for you to handle it from your object instead of have a breaking change like this request handle it.

@nknapp
Copy link
Collaborator

nknapp commented Jan 29, 2017

I wouldn't accept this as change to the library either, but I found this function in the compiler api, which indicates that it is possible to change this behaviour without changing Handlebars itself.

Docs

nknapp added a commit that referenced this issue Jan 29, 2017
While trying to answer #1302, I noticed that the compiler-api example did not work in (because `nameLookup` is actually at the prototype).
This example has a jsfiddle that proves it is working.
@nknapp nknapp mentioned this issue Jan 29, 2017
5 tasks
@nknapp nknapp closed this as completed in c997020 Jan 29, 2017
@nknapp
Copy link
Collaborator

nknapp commented Jan 29, 2017

I have updated the compiler-api example.

It does not solve your exact issue (it only performs lookups in lower-case, not case-insensitive), but it is a starting point. I believe you can find out the remaining parts by yourself.

However, looking at this Stackoverflow post, I believe implementing case-insensitive lookups will be a rather large performance impact (not just some).

What I describe in the example will probably reduce performance as well.

nknapp added a commit that referenced this issue Mar 9, 2017
Closes #1302 

While trying to answer #1302, I noticed that the compiler-api example did not work in (because `nameLookup` is actually at the prototype). This example has a jsfiddle that proves it is working.
It does not provide an solve the exact problem of the reporter, but it answers the question.
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 a pull request may close this issue.

3 participants