Compiling HTMLBars template with ember helper link-to gives an error


#1

Hello fellow Ember devs, I am trying to do something that might sound unorthodox but! I need to do it…

I am trying to compile a handlebars string to a plain HTML string which then I will need to insert into a pure js table library. I got to a partial result for now, it’s a bit hacky but it seems to be working except for one important issue, it will not compile helpers. The error I’m getting for example is Assertion Failed: A helper named ‘link-to’ could not be found I am fairly new to Ember, and I feel like I’m missing something, maybe a proper context that I am not setting which would allow to see the Ember helpers…

Thanks! :slight_smile:

function getHTMLTemplate() {

  const tpl = hbs`{{#link-to}}Go{{/link-to}}`; // gives an error

  const extendedComp = Ember.Component.extend({
          actions: {
            sayHi() {
              console.log('Hi');
            },
          },
  });

  const component = extendedComp.create({
          greeting: 'Hello',
          style:    'display:none;', // hide it
          layout:   tpl,
  });

  // Fetch the template
  component.createElement();
  const templateAsString = component.element.innerHTML;

  return templateAsString;
}

#2

I’m scared that you need something like that.