线之间拆分把手模板路径

时间:2018-10-08 09:36:35

标签: ember.js handlebars.js eslint

我正在开发一个EmberJS应用,在测试中,我多次出现:

this.render(hbs`{{directory1/directory2/directory3/directory4/directory5/directory6/directory1/directory8/ hasMyAction=(action hasMyAction)}}`);

我的ESLint最大行长为120。如何拆分上面的代码行?

2 个答案:

答案 0 :(得分:1)

// eslint-disable-next-line
this.render(hbs`{{directory1/directory2/directory3/directory4/directory5/directory6/directory1/directory8/
  hasMyAction=(action hasMyAction)
}}`);

据我所知,无法中断路径,但是您可以告诉ESLint忽略这行。

答案 1 :(得分:0)

也许是这样的:

const context = [
  'directory1',
  'directory2',
  'directory3',
  'directory4',
  'directory5',
  'directory6',
  'directory7'
].join('/');

const componentPath = `${context}/component-name`;

this.render(hbs`{{${componentPath} hasMyAction=(action hasMyAction)}}`);

不过,就我个人而言,我不确定反引号模板是否以这种方式进行插值,所以也许这是一种替代选择:

this.set('componentPath', componentPath);

this.render(hbs`{{component componentPath hasMyAction=(action hasMyAction)}}`