Flow-Router
https://github.com/kadirahq/flow-router
https://kadira.io/academy/meteor-routing-guide/content/introduction-to-flow-router
https://atmospherejs.com/meteorhacks/flow-router
meteor add meteorhacks:flow-router
How to use ?
FlowRouter.route('/perfil',{ subscriptions: function(params, queryParams) { {{ ... PUT HERE YOUR SUBSCRITIONS, NECESSARY COLLECTIONS ... }} {{ EVERY THING YOU PUT HERE GO TO YOUR MINIMONGO }} }, action: function(params) { {{ HERE CALL YOUR ROUTE }} } })
Example :
FlowRouter.route('/perfil',{ subscriptions: function(params, queryParams) { this.register('perfil', Meteor.subscribe('CurrentUser')); this.register('clients', Meteor.subscribe('Clients')); }, action: function(params) { if(Meteor.user()) { FlowLayout.render('Layout', {main: "Perfil"}); }else{ FlowRouter.go('/login'); } } })
WHERE
It’s my route : http://localhost:3000/perfil
/perfil
My subscriptions : ( collections )
CurrentUser and Clients
Look the publish.js file :
Meteor.publish('Clients',function(){ Meteor.users.find({roles: PERFIL.CLIENT},{sort:{name: -1}}); });
Perfil is the template :
<template name="Perfil"> {...} </template>