Can version: 2.2.5
Code
can.EJS.Helpers.prototype.elementHelper = function() {
return function(el) {
el.innerHTML = 'Simple';
};
};
var text = '<div id="hookup" <%= elementHelper() %>></div>';
var compiled = new can.EJS({
text: text
})
.render();
console.log(compiled);
Output
<div id="hookup" data-view-id='145'></div>
This was something that worked previously? I think the hookup
function needs to be called to find those data-view-id elements and call some behavior.
// File:
/can/view/ejs/ejs_test.js
// Failing test case
test('helpers', function () {
can.EJS.Helpers.prototype.simpleHelper = function () {
return 'Simple';
};
can.EJS.Helpers.prototype.elementHelper = function () {
return function (el) {
el.innerHTML = 'Simple';
};
};
var text = '<div><%= simpleHelper() %></div>';
var compiled = new can.EJS({
text: text
})
.render();
equal(compiled, '<div>Simple</div>');
text = '<div id="hookup" <%= elementHelper() %>></div>';
compiled = new can.EJS({
text: text
})
.render();
can.append(can.$('#qunit-fixture'), can.view.frag(compiled));
equal(can.$('#hookup')[0].innerHTML, 'Simple');
});
I think the modification didn’t turn out right. Is that the right code?
Actually I have just put test case name and assumed that you will get the code from /can/view/ejs/ejs_test.js
. I modified and put the complete code now. Please check.
Here is the complete code.
// File:
/can/view/ejs/ejs_test.js
// Failing test case
test('helpers', function () {
can.EJS.Helpers.prototype.simpleHelper = function () {
return 'Simple';
};
can.EJS.Helpers.prototype.elementHelper = function () {
return function (el) {
el.innerHTML = 'Simple';
};
};
var text = '<div><%= simpleHelper() %></div>';
var compiled = new can.EJS({
text: text
})
.render();
equal(compiled, '<div>Simple</div>');
text = '<div id="hookup" <%= elementHelper() %>></div>';
compiled = new can.EJS({
text: text
})
.render();
can.append(can.$('#qunit-fixture'), can.view.frag(compiled));
equal(can.$('#hookup')[0].innerHTML, 'Simple');
});
Justin
Can you give me some pointers how to fix this issue?