diff --git a/docs/route.md b/docs/route.md index 4931c07c..c4175e84 100644 --- a/docs/route.md +++ b/docs/route.md @@ -266,7 +266,7 @@ m.route.prefix("/my-app") ### Advanced component resolution -Instead of mapping a component to a route, you can specify a RouteResolver object. A RouteResolver object contains a `onmatch()` method and a optionally a `render()` method. +Instead of mapping a component to a route, you can specify a RouteResolver object. A RouteResolver object contains a `onmatch()` and/or a `render()` method. Both methods are optional but at least one of them must be present. ```javascript m.route(document.body, "/", { @@ -275,7 +275,7 @@ m.route(document.body, "/", { resolve(Home) }, render: function(vnode) { - return vnode + return vnode // equivalent to m(Home) }, } }) @@ -287,7 +287,7 @@ RouteResolvers are useful for implementing a variety of advanced routing use cas ### Wrapping a layout component -You can use a RouteResolver to wrap a layout around a component, or to pass parameters to a top level component +It's often desirable to wrap all or most of the routed components in a reusable shell (often called a "layout"). In order to do that, you first need to create a component that contains the common markup that will wrap around the various different components: ```javascript var Layout = { @@ -295,7 +295,27 @@ var Layout = { return m(".layout", vnode.children) } } +``` +In the example above, the layout merely consists of a `