# Element helpers are not working in ejs with canjs 2.2.5

**URL:** https://forums.bitovi.com/t/element-helpers-are-not-working-in-ejs-with-canjs-2-2-5/86
**Category:** CanJS
**Created:** [December 24, 2015, 12:41am UTC](https://forums.bitovi.com/t/element-helpers-are-not-working-in-ejs-with-canjs-2-2-5/86 "2015-12-24T00:41:01Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![arjunballa](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.bitovi.com/arjunballa/32/84_2.png) [@arjunballa](https://forums.bitovi.com/u/arjunballa)
#### Post date: [December 24, 2015, 12:41am UTC](https://forums.bitovi.com/t/element-helpers-are-not-working-in-ejs-with-canjs-2-2-5/86/1 "2015-12-24T00:41:01Z")

</div>

Can version: **2.2.5**  
**Code**

```auto
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>`

---

<div class="post-metadata">

### Author: ![justinbmeyer](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.bitovi.com/justinbmeyer/32/179_2.png) [@justinbmeyer](https://forums.bitovi.com/u/justinbmeyer)
#### Post date: [December 28, 2015, 5:52pm UTC](https://forums.bitovi.com/t/element-helpers-are-not-working-in-ejs-with-canjs-2-2-5/86/2 "2015-12-28T17:52:09Z")

</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.

---

<div class="post-metadata">

### Author: ![arjunballa](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.bitovi.com/arjunballa/32/84_2.png) [@arjunballa](https://forums.bitovi.com/u/arjunballa)
#### Post date: [December 28, 2015, 6:01pm UTC](https://forums.bitovi.com/t/element-helpers-are-not-working-in-ejs-with-canjs-2-2-5/86/3 "2015-12-28T18:01:05Z")

</div>

```auto
// 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');
});

```

---

<div class="post-metadata">

### Author: ![justinbmeyer](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.bitovi.com/justinbmeyer/32/179_2.png) [@justinbmeyer](https://forums.bitovi.com/u/justinbmeyer)
#### Post date: [December 30, 2015, 12:04am UTC](https://forums.bitovi.com/t/element-helpers-are-not-working-in-ejs-with-canjs-2-2-5/86/4 "2015-12-30T00:04:20Z")

</div>

I think the modification didn’t turn out right. Is that the right code?

---

<div class="post-metadata">

### Author: ![arjunballa](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.bitovi.com/arjunballa/32/84_2.png) [@arjunballa](https://forums.bitovi.com/u/arjunballa)
#### Post date: [December 30, 2015, 2:39am UTC](https://forums.bitovi.com/t/element-helpers-are-not-working-in-ejs-with-canjs-2-2-5/86/5 "2015-12-30T02:39:01Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![arjunballa](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.bitovi.com/arjunballa/32/84_2.png) [@arjunballa](https://forums.bitovi.com/u/arjunballa)
#### Post date: [January 4, 2016, 9:45pm UTC](https://forums.bitovi.com/t/element-helpers-are-not-working-in-ejs-with-canjs-2-2-5/86/6 "2016-01-04T21:45:47Z")

</div>

Here is the complete code.

```auto
// 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');
});

```

---

<div class="post-metadata">

### Author: ![arjunballa](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.bitovi.com/arjunballa/32/84_2.png) [@arjunballa](https://forums.bitovi.com/u/arjunballa)
#### Post date: [January 6, 2016, 7:04pm UTC](https://forums.bitovi.com/t/element-helpers-are-not-working-in-ejs-with-canjs-2-2-5/86/7 "2016-01-06T19:04:55Z")

</div>

Justin  
Can you give me some pointers how to fix this issue?
