Skip to content

Commit

Permalink
template.data clarification
Browse files Browse the repository at this point in the history
  • Loading branch information
dgreensp committed Aug 14, 2012
1 parent 01c7afe commit 4301dff
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
1 change: 1 addition & 0 deletions packages/templating/deftemplate.js
Expand Up @@ -123,6 +123,7 @@
tmpl.render && tmpl.render.call(template);
},
destroy: function () {
// template.data is already set from previous callbacks
tmpl.destroy &&
tmpl.destroy.call(templateObjFromLandmark(this));
delete templateInstanceData[this.id];
Expand Down
17 changes: 9 additions & 8 deletions packages/templating/templating_tests.js
Expand Up @@ -80,18 +80,19 @@ Tinytest.add("templating - event handler this", function(test) {
Template.test_event_data_with.TWO = {str: "two"};
Template.test_event_data_with.THREE = {str: "three"};

Template.test_event_data_with.events({
'click': function(event, template) {
test.isTrue(this.str);
test.equal(template.data.str, "one");
event_buf.push(this.str);
}
});

var event_buf = [];
var tmpl = OnscreenDiv(
Meteor.render(function () {
var html = Template.test_event_data_with(
return Template.test_event_data_with(
Template.test_event_data_with.ONE);
html = Spark.attachEvents({
'click': function() {
test.isTrue(this.str);
event_buf.push(this.str);
}
}, html);
return html;
}));

var divs = tmpl.node().getElementsByTagName("div");
Expand Down

0 comments on commit 4301dff

Please sign in to comment.