-
Notifications
You must be signed in to change notification settings - Fork 8
增加helper的注册 #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
增加helper的注册 #4
Conversation
atian25
left a comment
There was a problem hiding this 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){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不是很明白,loadFiles实现是原来的方法,没有改过
There was a problem hiding this comment.
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] + ")")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
eval ......
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
请提供不用eval的处理方法
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
eslint 没过
增加了helper的注册