Update 11-page-menu.md
This commit is contained in:
parent
a864b2aad5
commit
9a7b586548
1 changed files with 5 additions and 5 deletions
|
@ -2,17 +2,17 @@
|
||||||
|
|
||||||
### Page Menu
|
### Page Menu
|
||||||
|
|
||||||
Now we have some sweet dynamic pages. But nobody can find them.
|
Now we have made a few nice dynamic pages. But nobody can find them.
|
||||||
|
|
||||||
Let's fix that now. In this chapter we will create a menu with links to all our pages.
|
Let's fix that now. In this chapter we will create a menu with links to all of our pages.
|
||||||
|
|
||||||
When we have a menu, we will want to be able to reuse the same code on multiple page. We could create a separate file and include it every time, but there is a better solution.
|
When we have a menu, we will want to be able to reuse the same code on multiple pages. We could create a separate file and include it every time, but there is a better solution.
|
||||||
|
|
||||||
It is more practical to have templates that are able to extend other templates, like a layout for example. Then we can have all the layout related code in a single file and we don't have to include header and footer files in every template.
|
It is more practical to have templates that are able to extend other templates, like a layout for example. Then we can have all the layout related code in a single file and we don't have to include header and footer files in every template.
|
||||||
|
|
||||||
Sadly our implementation of mustache does not support this. We could write code to work around this, which will take time and could introduce some bugs. Or we could switch to a library that already supports this and is well tested. [Twig](http://twig.sensiolabs.org/) for example.
|
Our implementation of mustache does not support this. We could write code to work around this, which will take time and could introduce some bugs. Or we could switch to a library that already supports this and is well tested. [Twig](http://twig.sensiolabs.org/) for example.
|
||||||
|
|
||||||
Now you might wonder why we didn't start with Twig right away. This is a good example to show why using interfaces and writing loosely-coupled code is a good idea.
|
Now you might wonder why we didn't start with Twig right away. Because this is a good example to show why using interfaces and writing loosely-coupled code is a good idea. Like in the real world, the requirements suddenly changed and now our code needs to adapt.
|
||||||
|
|
||||||
Remember how you created a `MustacheRenderer` in [chapter 9](09-templating.md)? This time, we create a `TwigRenderer` that implements the same interface.
|
Remember how you created a `MustacheRenderer` in [chapter 9](09-templating.md)? This time, we create a `TwigRenderer` that implements the same interface.
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue