-
Notifications
You must be signed in to change notification settings - Fork 123
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
Remove expressive layouts code duplication #1225
Remove expressive layouts code duplication #1225
Conversation
const markbinder = new MarkBind(); | ||
const template = {}; | ||
template[LAYOUT_PAGE_BODY_VARIABLE] = pageData; | ||
generateExpressiveLayout(pageData, fileConfig, markbinder) { |
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.
passing the parser (markbinder
) isn't very clean, but will be dealt with in #1189 in full (making it an instance variable)
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.
The refactor looks good! Just a couple of thoughts about lifting the I/O part up to Page.js
:
- Leaving it in will reduce duplication of the
fs.readFileAsync
call we have to make before everyincludeFile
call. - It kinda makes sense semantically (to me at least) that
includeFile
does the reading of the file. Also, since there should be no other reason for us to use the file content outside of this function, I think not having to pass the file content toincludeFile
will make the call site a little cleaner.
What are your thoughts about this?
Hmm, my viewpoint was from a perspective of concerns - I think Its a really small thing though, I'm fully open to reverting it. What do you think? |
That makes sense as well. I'm happy to go with this and move towards removing I/O concerns from the parser. Let's get the conflicts resolved and we can get this in! |
cb9f0ed
to
7bb7462
Compare
Done! |
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.
LGTM
What is the purpose of this pull request? (put "X" next to an item, remove the rest)
• [x] Other, please explain: small code refactor
What is the rationale for this request?
Merge the logic for expressive layouts in
parser
intoincludeFile
What changes did you make? (Give an overview)
additionalVariables
, which is introduced toincludeFile
)includeFile
intoPage.js
instead which was the case forincludeData
for expressive layouts ( small change, but I think its cleaner to move the initial I/O intoPage.js
)Is there anything you'd like reviewers to focus on?
na
Testing instructions:
npm run test
Proposed commit message: (wrap lines at 72 characters)
Remove expressive layouts code duplication