{"issue":{"created_at":"2011-11-17T01:51:11Z","state":"closed","updated_at":"2011-11-18T15:47:00Z","user":{"gravatar_id":"9668c440d477e73a5a3ae86e061efc56","id":917189,"url":"https://api.github.com/users/azicchetti","login":"azicchetti","avatar_url":"https://secure.gravatar.com/avatar/9668c440d477e73a5a3ae86e061efc56?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png"},"comments":3,"body":"Hi,\r\nI think there should be a way to define the scope of a templating function.\r\n\r\nI find it convenient to do this thing in my templates:\r\n<% var view=this; %> .... <%= view.doSomethingThatOutputsSomething(var1,var2) %>\r\n\r\nwhere \"this\" is an instance of backbone view. To preserve this functionality, which was present in older versions of underscore, I had to patch the return statement of _.template():\r\n\r\nreturn data ? func(data, _) : function(data) { return func.call(this,data, _) };\r\n\r\nI prefer to define \"doSomethingThatOutputsSomething\" in the view class, so that I can inherit its functionality in subclasses, that's why this is a very important issue to me.\r\n\r\nThank you!","assignee":null,"labels":[{"name":"question","color":"a8438d","url":"https://api.github.com/repos/documentcloud/underscore/labels/question"}],"id":2264498,"pull_request":{"patch_url":null,"html_url":null,"diff_url":null},"number":372,"title":"Template function scope","closed_at":"2011-11-18T14:17:24Z","html_url":"https://github.com/documentcloud/underscore/issues/372","milestone":null,"url":"https://api.github.com/repos/documentcloud/underscore/issues/372"},"action":"created","comment":{"created_at":"2011-11-18T15:47:00Z","updated_at":"2011-11-18T15:47:00Z","user":{"gravatar_id":"32652ed5b8fbd2ecdb1c78e9ac567b4b","id":4732,"url":"https://api.github.com/users/jashkenas","login":"jashkenas","avatar_url":"https://secure.gravatar.com/avatar/32652ed5b8fbd2ecdb1c78e9ac567b4b?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png"},"body":"I see.\r\n\r\nI'm afraid that it's a necessary change to make Underscore namespacing work correctly ... I'm not sure what we can do about it, unless you have a patch in mind.","id":2790542,"url":"https://api.github.com/repos/documentcloud/underscore/issues/comments/2790542"}}