ecd296eaf7
This reverts commit cd55c0cda3310c06abe989b8d145d9946945ae8d, reversing changes made to 14af8cb7a9e7fc0a65178e6ca7708b3f395f0d70.
20 lines
543 B
JavaScript
20 lines
543 B
JavaScript
import Helper from '@ember/component/helper';
|
|
import { inject as service } from '@ember/service';
|
|
|
|
// simple mustache regexp `/{{item.Name}}/`
|
|
const templateRe = /{{([A-Za-z.0-9_-]+)}}/g;
|
|
let render;
|
|
export default class RenderTemplateHelper extends Helper {
|
|
@service('encoder') encoder;
|
|
constructor() {
|
|
super(...arguments);
|
|
if (typeof render !== 'function') {
|
|
render = this.encoder.createRegExpEncoder(templateRe, encodeURIComponent, false);
|
|
}
|
|
}
|
|
|
|
compute([template, vars]) {
|
|
return render(template, vars);
|
|
}
|
|
}
|