Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Add cookbook entry for accessing common data in templates #615

Merged
merged 3 commits into from
May 14, 2018
Merged

Add cookbook entry for accessing common data in templates #615

merged 3 commits into from
May 14, 2018

Conversation

geerteltink
Copy link
Member

@geerteltink geerteltink commented May 7, 2018

As the title says: It adds a cookbook entry for accessing common data in templates.

  • Are you creating a new feature?
    • Why is the new feature needed? What purpose does it serve?
    • How will users use the new feature?
    • Add only one feature per pull request; split multiple features over multiple pull requests
    • Add documentation for the new feature.
    • Add a CHANGELOG.md entry for the new feature.

Copy link
Member

@weierophinney weierophinney left a 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>
Copy link
Member

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
Copy link
Member

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
Copy link
Member

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):
Copy link
Member

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
Copy link
Member

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.

@weierophinney weierophinney merged commit 2550ddf into zendframework:master May 14, 2018
weierophinney added a commit that referenced this pull request May 14, 2018
Add cookbook entry for accessing common data in templates
weierophinney added a commit that referenced this pull request May 14, 2018
Once the link is created, it's a single line anyways.
weierophinney added a commit that referenced this pull request May 14, 2018
weierophinney added a commit that referenced this pull request May 14, 2018
@weierophinney
Copy link
Member

Thanks, @xtreamwayz!

@geerteltink geerteltink deleted the feature/cookbook-access-data branch May 14, 2018 15:13
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants