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

Conflicts with Underscore.JS #43

Closed
tauren opened this issue Jan 11, 2011 · 4 comments
Closed

Conflicts with Underscore.JS #43

tauren opened this issue Jan 11, 2011 · 4 comments

Comments

@tauren
Copy link

tauren commented Jan 11, 2011

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.

@dvv
Copy link

dvv commented Jan 11, 2011

I'd vote for reserving _ for underscore.js. This lib is of wide use, good would be to just respect this.

@jzaefferer
Copy link
Contributor

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.

@dvv
Copy link

dvv commented Jan 11, 2011

Exactly. Please consider renaming.

TIA,
--Vladimir

@BorisMoore
Copy link
Owner

This is already being tracked as https://github.com/jquery/jquery-tmpl/issues/#issue/10. It will be renamed. See linked issue...

This issue was closed.
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

No branches or pull requests

4 participants