Skip to content

Conversation

@yuyang1004
Copy link

增加了helper的注册

Copy link
Member

@atian25 atian25 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • 缺少单元测试
  • commit message 请符合规范

return loadFiles(helpersPath);
}

function loadFiles(filesPath){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不是很明白,loadFiles实现是原来的方法,没有改过

Copy link
Member

@atian25 atian25 Nov 23, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

原来的方法是因为要加载非 js 文件(虽然它那个也可以改为 loader)。
而你这里是一个 js,直接用 egg 的 loader 即可。


const helpers = loadHelper(app);
for (const key of Object.keys(helpers)) {
handlebars.registerHelper(key, eval("(" + helpers[key] + ")"));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

eval ......

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

请提供不用eval的处理方法

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

handlebars.registerHelper 第二个参数不就是一个 function 了, load 进来后就是了,为什么要 eval ?

const result = {};
const files = fs.readdirSync(filesPath);
for (let name of files) {
const file = path.join(filesPath, name);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

eslint 没过

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants