0
votes

In my meteor project(ironTest), I have three files created by the project: ironTest.css, ironTest.html, ironTest.js. I have removed all the content of ironTest.js and replaced it with:

Router.map(function(){
  this.route('home', {path: '/'} );
     this.route('hello', {path: '/hello'});
});

Inside the ironTest.html, I have:

<head>
    <title>ironTest</title>
</head>

<body>
    <h1>Welcome to Meteor!</h1>
</body>

<template name="hello">
    <button>Click Me</button>
    <p>You've pressed the button times.</p>
</template>

<template name="home">
    This is the home template.
</template>

I also have the iron router added in the project as I can see that in the packages file:

# Meteor packages used by this project, one per line.
# Check this file (and the other files in this directory) into your repository.
#
# 'meteor add' and 'meteor remove' will edit this file for you,
# but you can also edit it by hand.

meteor-platform
autopublish
insecure
iron-router

When I open the localhost:3000 after running the meteor command, I see a blank page. Why the home template is not rendered when I have set that as the root using the Router.map function?

1

1 Answers

2
votes

Assuming you are running a recent version of meteor (> 1.0), the main problem is you are not adding the iron-router package correctly. Modify your .meteor/packages to replace iron-router with iron:router.

Because IR currently has a mostly backwards-compatible API, your code should now work. To use the 1.x API, change your route specifications to:

Router.route('/', function () {
  this.render('home');
}, {
  name: 'home'
});

Router.route('/hello', function () {
  this.render('hello');
});

For more details, see the docs.