Extract component preprocessor into a class #1309
Merged
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.
What is the purpose of this pull request? (put "X" next to an item, remove the rest)
• [x] Other, please explain:
Another part of #810 (leaving
render
and a few other utility methods to refactor out inParser.js
)What changes did you make? (Give an overview)
componentPreprocessor
a class to avoid passing configuration parameters all throughout its methodsincludeFile
intocomponentPreprocessor
to consolidate functionalityIs there anything you'd like reviewers to focus on?
na
Testing instructions:
npm run test
passesProposed commit message: (wrap lines at 72 characters)
Extract componentPreprocessor into a class
The includeFile process depends on heavily on configuration parameters
being passed repeatedly throughout its functions (in
componentPreprocessor).
Let's make componentPreprocessor a class instead, passing these
configurations as instance properties.
The Page model's included sources are collected in instance properties
of Parser and then reconsolidated in page generation.
Let's create a PageSources model to hold these properties instead, and
correspondingly move them to the ComponentPreprocessor class.
This clearly defines the schema and purpose of a Page's sources.
The entry point to ComponentPreprocessor resides in the includeFile
method, which resides in Parser.
Let's move this to the ComponentPreprocessor class to benefit from the
instance properties, and also to consolidate include functionality
as well.