Open
Conversation
atian25
requested changes
Nov 10, 2017
| return loadFiles(helpersPath); | ||
| } | ||
|
|
||
| function loadFiles(filesPath){ |
Member
There was a problem hiding this comment.
Author
There was a problem hiding this comment.
不是很明白,loadFiles实现是原来的方法,没有改过
Member
There was a problem hiding this comment.
原来的方法是因为要加载非 js 文件(虽然它那个也可以改为 loader)。
而你这里是一个 js,直接用 egg 的 loader 即可。
|
|
||
| const helpers = loadHelper(app); | ||
| for (const key of Object.keys(helpers)) { | ||
| handlebars.registerHelper(key, eval("(" + helpers[key] + ")")); |
Member
There was a problem hiding this comment.
handlebars.registerHelper 第二个参数不就是一个 function 了, load 进来后就是了,为什么要 eval ?
| const result = {}; | ||
| const files = fs.readdirSync(filesPath); | ||
| for (let name of files) { | ||
| const file = path.join(filesPath, name); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
增加了helper的注册