I'm creating a Meteor application. When first creating application, Meteor has put this sample code in hello.html
<head>
<title>hello</title>
</head>
<body>
<h1>Welcome to Meteor!</h1>
{{> hello}}
</body>
<template name="hello">
Hello World Template
</template>
I install Iron-Router
package. then here is my lib/Router.js
file:
Router.route('/', function () {
this.render('post_template');
});
And here is my client/templates/posts/post_template.html
<template name="post_template">
Example Template
</template>
I don't know why when I run this application. The result is:
HelloWorld Template
Example Template
In other word, which part of Meteor's configuration that load hello.html
as default page, and then append all other templates in routing inside ?
Thanks :)
IR will append to the <body>
if it exists (and otherwise add one for you) so it's recommended that you remove the entire <body>
tag.
You are actually safe to remove the hello.html
entirely (since you also don't need the hello
template). If you want to keep the head
tag, you could just modify the file to look like:
<head>
<title>hello</title>
</head>
To understand why hello.html
is being included, see the Structuring your application section of your docs:
HTML files in a Meteor application are treated quite a bit differently from a server-side framework. Meteor scans all the HTML files in your directory for three top-level elements:
<head>
,<body>
, and<template>
. The head and body sections are separately concatenated into a single head and body, which are transmitted to the client on initial page load.
So all of your html files are always included. If you don't want to include them, you need to remove them from your app.