-
Notifications
You must be signed in to change notification settings - Fork 196
Adding parameters to templates before render-time #143
Adding parameters to templates before render-time #143
Conversation
… null, not empty string.
… null, not empty string.
* @param array|object $params | ||
* @param string|null $name | ||
*/ | ||
public function addParameters($params, $name = null) |
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 method also needs to be added to the interface; otherwise, an implementation could omit it, leaving developers depending on concretions instead of abstractions.
Some general notes:
Finally, you'll need to rebase, as #139 renamed With regards to the ZF2 implementation, I'd handle it in |
Thanks for the feedback! I'll get on with that then. |
@kynx I've been working on the suggestions this morning as well; I can do a PR against your branch shortly, if you'd like. |
… null, not empty string.
… null, not empty string.
…ive into template-add-parameter * 'template-add-parameter' of github.com:kynx/zend-expressive: Added Plates tests CS fix Fix for adding shared params to Plates. Default for template name now null, not empty string. Fix for adding shared params to Plates. Default for template name now null, not empty string. Fixed failing tests TemplateInterface::addParameters() method for building up parameters before rendering
@weierophinney Please do! Looks like I messed up the rebase tho :( |
Adding parameters to templates before render-time
- Adds the method `addDefaultParam($templateName, $key, $value)` to `TemplateRendererInterface`; define a TEMPLATE_ALL constant. Replaces `addParameters()`. - Renames `AddParametersTrait` to `DefaultParamsTrait` - Renames `$templateParams` to `$defaultParams` - Renames `addParameters()` to `addDefaultParam()` - Updates PlatesRenderer to the interface changes. - Modifies Twig and ZendView renderers to use the new trait. - Wrote tests for the behavior for each renderer.
- Adds the method `addDefaultParam($templateName, $key, $value)` to `TemplateRendererInterface`; define a TEMPLATE_ALL constant. Replaces `addParameters()`. - Renames `AddParametersTrait` to `DefaultParamsTrait` - Renames `$templateParams` to `$defaultParams` - Renames `addParameters()` to `addDefaultParam()` - Updates PlatesRenderer to the interface changes. - Modifies Twig and ZendView renderers to use the new trait. - Wrote tests for the behavior for each renderer.
@kynx — I've created #151 so I could run Travis-CI checks; at this point, those are all passing. I've also added documentation of the new interface method. We have two options at this point:
Let me know! |
@kynx I've gone ahead and merged both branches at this time; thanks for the new feature! |
My first run at #142. Only tried it with Plates so far. There's probably a better way to do this with ZendView, but I'm a little hazy on that. Let me know if I'm on the right track and I'll do the tests and docs.