meteor-space / ui

Pattern-agnostic base UI package to gain control over your Meteor UI
MIT License
121 stars 15 forks source link

Routing question #5

Closed zephraph closed 9 years ago

zephraph commented 9 years ago

How would one go about rendering a route at a particular point in a template?

In the todo-mvc example the route is rendered at the bottom of the body. I'd like to render the route at a certain part in the template.

i.e.

<body>

  {{>menu}}
  {{>sidebar}}

  <div class="content">
    {{>view}}
 </div>

</body>

where the template corresponding to the route I'm traversing to is rendered in view. The idea here is I want view to be an area where I can display content from different modules based on routes.

So /dashboard would render the main template for the dashboard module in the view area....

DominikGuzei commented 9 years ago

Hey @zephraph space:ui just uses the iron:router package, the Space.ui.RouteController is just a simple class that declares the Router as dependency.

that said, in your example you just have to define a layout template for your routes:

<template name="app_layout">

  {{>menu}}
  {{>sidebar}}

  <div class="content">
    {{> yield}}
 </div>
</template>

and then set it as the default layout for all routes like that:

class @IndexController extends Space.ui.RouteController

  configure: ->

     # set default layout for all routes
    @router.configure layoutTemplate: 'app_layout'

    # handle specific route for a module
    @router.route '/some/path', name: 'some_module_template'