Question

I want to render each article in my meteor Articles collection. (File located in myProject/collections/collections.js so it should be available for both client and server)

Code in collections.js:

Articles = new Meteor.Collection('articles');

I've got the autopublish package installed and and i have inserted an object in the Article collection via the Chrome console and verified the insert via the console with: Articles.findOne()

Articles.insert({name: 'HTML5', description: 'HTML5 for beginners', src: 'https://www.youtube.com/watch?v=9gTw2EDkaDQ'})

What i have got so far is:

<head>
  <title>Articles</title>
</head>

<body>
  {{> main}}
</body>

My main template is the one that won't show the articles.

<template name="main">
  <div class="container-fluid">
    {{#each articles}}
      {{> article}}
    {{/each}}
  </div>
</template>

And my article template which should be rendered for each of the objects in my Articles collection, looks like this:

<template name="article">
  <div class="item well span4">
    <iframe height="{{height}}" src="{{src}}"></iframe>
    <hr>
    <h4 class="muted">{{name}}</h4>
    <p>{{description}}</p>  
   </div>
</template>

What do i need to add to render this article? And what would i have to do to render the article if i were remove the autopublish package?

Was it helpful?

Solution

What do i need to add to render this article?

You need to tell what your main template how to calculate the field articles. You simply do that by calling the helpers method on the template.

And what would i have to do to render the article if i were remove the autopublish package?

You would need to create a publish, so the clients can get the documents in the collection by subscribing to it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top