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

Templates broken in 1.7 #1928

Closed
acl0056 opened this issue Nov 8, 2014 · 5 comments
Closed

Templates broken in 1.7 #1928

acl0056 opened this issue Nov 8, 2014 · 5 comments
Labels

Comments

@acl0056
Copy link

acl0056 commented Nov 8, 2014

It seems like the API for templates changed. Not sure if that is considered a feature, but I would consider it a bug as it breaks everything I have ever done with underscore templates.

The issue is that I can no longer pass in data and get the rendered template back. It now returns a function instead of a string.

@romamatusevich
Copy link

According 1.7 changelog: "Underscore templates no longer accept an initial data object. _.template always returns a function now". So this is the change without backward compatibility.

@acl0056
Copy link
Author

acl0056 commented Nov 11, 2014

Right. Isn't that a terrible idea? What if someone has server side templating with node.js and they unwittingly update to underscore 1.7? They are screwed. Why not just check whether an object is a settings object or a data object based on what keys the object has?

@jridgewell
Copy link
Collaborator

See #1736 for reasoning, and #1805 for arguments that underscore should be following semver.

Either way, you can update your own code to _.template(templateStr)(data).

@akre54 akre54 added the invalid label Nov 12, 2014
@akre54 akre54 closed this as completed Nov 12, 2014
@acl0056
Copy link
Author

acl0056 commented Nov 14, 2014

It wasn't a question of how to work around the issue. I am actually embracing the change. Without considering all of the code this breaks, from a performance and API perspective it makes sense. It was just a rude surprise to update my node server and have my email templates stop working.

Thanks for pointing out the other issue threads. I enjoyed reading the discussions.

@cancerberoSgx
Copy link

And I thought if there was one js library I wound't have compatibility problems would be underscore.... and in a minor version !!! there are no excuses for this... :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants