tag:blogger.com,1999:blog-581197352358126527.post6893526987825548812..comments2024-03-29T03:21:30.339-07:00Comments on japh(r) by Chris Strom: Temporarily Overriding Template Settings in Underscore.js & Backbone.jsAnonymoushttp://www.blogger.com/profile/00135361916531185929noreply@blogger.comBlogger2125tag:blogger.com,1999:blog-581197352358126527.post-77437588390888701122013-12-31T08:32:02.767-08:002013-12-31T08:32:02.767-08:00ofcourse it will not work, because he tries to cop...ofcourse it will not work, because he tries to copy an object simply by save it in a variable. But what he actually do is that he creating another variable that links to the SAME OBJECT. <br />var orig_settings = _.templateSettings;<br />lolAnonymoushttps://www.blogger.com/profile/02278609853848135950noreply@blogger.comtag:blogger.com,1999:blog-581197352358126527.post-21498858496649663292012-08-14T16:50:09.130-07:002012-08-14T16:50:09.130-07:00I just wanted to post some information for anyone ...I just wanted to post some information for anyone else that needed to do this. I was using this method that Chris described and it worked well until I needed to integrate this with some other views. The settings wouldn't return to the original state after calling _.template()<br /><br />However, I was digging into the underscore code and noticed that you can pass settings to the function and it works as a temporary call as mentioned above.<br /><br />Could be that underscore has updated a lot over the past year and it's "new" anyway, to do this now you'll want to do something like this:<br /><br />template: _.template( $('#your_template').html(), null, { interpolate : /\{\{([\s\S]+?)\}\}/g };),Unknownhttps://www.blogger.com/profile/03041964120998086002noreply@blogger.com