-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Conflicts with Underscore.JS #43
Comments
I'd vote for reserving |
Afaik the _ variable is only internally used and not a part of the documented public API (see http://api.jquery.com/category/plugins/templates/ ). So it should be safe to rename it. |
Exactly. Please consider renaming. TIA, |
This is already being tracked as https://github.com/jquery/jquery-tmpl/issues/#issue/10. It will be renamed. See linked issue... |
Inside of the function tiCalls(), the value of _ is set to the content. This makes it more difficult to use the Underscore.JS library ( http://documentcloud.github.com/underscore/ ) within a template.
I'd like to propose that __ (double underscore) be used inside of jquery.tmpl.js instead of _ (single underscore) to avoid this collision.
If this change is likely to break existing templates, then perhaps there could be a noconflict option that would avoid using a single underscore and leave it as it was inside the template processing context.
For instance, with the following data:
var objects = {a:1, b:2, c:3};
This template won't work:
There are ${_.size(objects)} objects.
This can be worked around by defining a new global for underscore:
var underscore = _;
Then in the template:
There are ${underscore.size(objects)} objects.
The text was updated successfully, but these errors were encountered: