-
Notifications
You must be signed in to change notification settings - Fork 3
allow for shared or global model extension when rendering all ingredi… #15
Conversation
Can you explain the motivation for this a bit more, please? I would expect this to be done via |
@lawnsea the motivation is that certain things (icons.svg) remain as something all ingredients expect to have available to their model. It would be redundant/unnecessary to expose the contents of the icons.svg sprite by hand in every ingredient's model. The stash PR associated with bechamel illustrates how this change is used. |
@lawnsea I still think we need to land this or something like it. The module allows you to override the It is not very useful to let me override the default-preview unless I also have some level of control over the model that is thrown at that preview template. |
0a563f4
to
8f55827
Compare
Just so I'm clear, you mean that they expect them to appear at a particular absolute path in the model, right? Specifically, the templates reference
This is a compelling argument. I'm in favor of landing this if you remove the unnecessary |
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.
This looks ok, but I'd like to remove the commonModel
code and rename globalModel
to basePreviewModel
.
lib/middleware/preview.js
Outdated
* @param {Object} [config.globalModel] - optional model that will be extended | ||
* into the root object before rendering. If your ingredients contain @root | ||
* references, you'll want to specify those things here. | ||
* @param {Object} [config.commonModel] - optional model that will be extended |
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.
I don't think we need this. The ingredients should instead require a common base model in their model.js
entrypoint.
lib/middleware/preview.js
Outdated
@@ -208,6 +218,12 @@ function previewMiddleware(config, req, res, next) { | |||
* is used. | |||
* @param {Object} [config.helpers] - optional map of Handlebars helpers to | |||
* register | |||
* @param {Object} [config.globalModel] - optional model that will be extended |
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.
This is really a base preview model. Let's call it basePreviewModel
.
c6f5c4e
to
76ea996
Compare
Published in v1.0.2 |
There may be cases where you want to specify global model properties that are always included when rendering a preview, regardless of ingredient.
This change makes that possible.