-
Notifications
You must be signed in to change notification settings - Fork 195
Add cookbook entry for accessing common data in templates #615
Add cookbook entry for accessing common data in templates #615
Conversation
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.
Overall, quite solid! I've noted a few changes, after which I can merge.
Thanks!
@@ -0,0 +1,6 @@ | |||
<noscript><meta http-equiv="refresh" content="0; url=/zend-expressive/v3/cookbook/access-common-data-in-templates/"></noscript> |
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 file is not needed. We only have the existing redirect files as we added versioning at a later date. (The redirects are from the non-versioned pages to the versioned ones.)
@@ -0,0 +1,75 @@ | |||
# How Can I Access Common Data In Templates? | |||
|
|||
This is a question that's asked a lot of times. How can I make common data like |
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.
We can omit the first sentence; the fact that we have a recipe is indicative that it's a frequently asked question.
|
||
This is a question that's asked a lot of times. How can I make common data like | ||
request attributes, the current route name, etc. available into all template. | ||
The answer is pretty easy actually. All that is needed is a middleware and |
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.
Avoid words and phrases like "easy", "actually", "simply", "simple", "just", "all that is needed", etc. What is easy for the author is often difficult for the person looking for a solution, which is why they're reading the document in the first place.
``` | ||
|
||
Next you need to create a factory and register it. This is easy with | ||
[zend-expressive-tooling](../reference/cli-tooling.md): |
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.
s/This is easy with/You can generate a factory with/
[zend-expressive-tooling](../reference/cli-tooling.md): | ||
|
||
```bash | ||
./vendor/bin/expressive factory:create App\Middleware\TemplateDefaultsMiddleware |
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.
For console commands, start the line with a $
prompt.
Add cookbook entry for accessing common data in templates
Once the link is created, it's a single line anyways.
Thanks, @xtreamwayz! |
As the title says: It adds a cookbook entry for accessing common data in templates.
CHANGELOG.md
entry for the new feature.