# Use custom helpers in Handlebars which are loaded from an api

**URL:** <https://discuss.emberjs.com/t/use-custom-helpers-in-handlebars-which-are-loaded-from-an-api/5970>\
**Category:** Uncategorized\
**Created:** [July 25, 2014, 2:04pm UTC](https://discuss.emberjs.com/t/use-custom-helpers-in-handlebars-which-are-loaded-from-an-api/5970 "2014-07-25T14:04:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![harianus](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/harianus/32/14069_2.png) [@harianus](https://discuss.emberjs.com/u/harianus)\
**Post date:** [July 25, 2014, 2:04pm UTC](https://discuss.emberjs.com/t/use-custom-helpers-in-handlebars-which-are-loaded-from-an-api/5970/1 "2014-07-25T14:04:04Z")

</div>

With ember-cli I use some handlebars which are loaded from an api. I’m using variables in the Handlebars templates, but now it would be nice to get `render`, `bind-attr` and a `custom-helper` working.

```
// app/helpers/view-helper.js
var ViewTemplateHelper = Ember.Handlebars.makeBoundHelper(function(template, context) {

  if (Ember.isEmpty(template)) {
    return;
  }
  else if (Ember.isArray(template)) {
    template = template.get('firstObject.value');
  }
  else {
    template = template.get('value');
  }

  context = context || this;

  var dummy = Ember.View.extend({
    classNames: ['view-template'],
    context: context,
    template: Ember.Handlebars.compile(template)
  });

  var view = dummy.create();
  var $elem = null;

  Ember.run(function() {
    $elem = $('<div>');
    view.appendTo($elem);
  });

  return new Ember.Handlebars.SafeString($elem.html());
});

export default ViewTemplateHelper;

```

Just calling the helper like this

```
// app/templates/blog-list.hbs
{{view-template blog}}

```

When I use this Handlebar this code works fine

```
<h1>{{blog.title}}</h1>

```

But when using `render`, `bind-attr`, `custom-helper`,

```
{{render 'blog/cover' blog.image}}

```

the console logs an error:

```
Uncaught TypeError: Cannot read property 'container' of null

```

Does anyone know how to use custom helpers in the Handlebars loaded from the api?

---

<div class="post-metadata">

**Author:** ![harianus](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/harianus/32/14069_2.png) [@harianus](https://discuss.emberjs.com/u/harianus)\
**Post date:** [July 25, 2014, 2:22pm UTC](https://discuss.emberjs.com/t/use-custom-helpers-in-handlebars-which-are-loaded-from-an-api/5970/2 "2014-07-25T14:22:56Z")

</div>

Solved by using this method: [How do you render a view from within a handlebars helper that takes dynamic content? - #3 by seilund](http://discuss.emberjs.com/t/how-do-you-render-a-view-from-within-a-handlebars-helper-that-takes-dynamic-content/984/3)

See stackoverflow: [javascript - Use custom helpers in Handlebars which are loaded from an api - Stack Overflow](http://stackoverflow.com/questions/24955389/use-custom-helpers-in-handlebars-which-are-loaded-from-an-api/24957959#24957959)
