【发布时间】:2014-04-27 07:10:11
【问题描述】:
我想渲染我的流星文章集合中的每篇文章。
(文件位于myProject/collections/collections.js,因此它应该可用于客户端和服务器)
collections.js 中的代码:
Articles = new Meteor.Collection('articles');
我已经安装了 autopublish 包,并且我通过 Chrome 控制台在文章集合中插入了一个对象,并通过控制台验证了插入:Articles.findOne()
Articles.insert({name: 'HTML5', description: 'HTML5 for beginners', src: 'https://www.youtube.com/watch?v=9gTw2EDkaDQ'})
到目前为止我得到的是:
<head>
<title>Articles</title>
</head>
<body>
{{> main}}
</body>
我的主要模板是不显示文章的模板。
<template name="main">
<div class="container-fluid">
{{#each articles}}
{{> article}}
{{/each}}
</div>
</template>
我的文章模板应该为我的文章集合中的每个对象呈现,如下所示:
<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>
我需要添加什么来呈现这篇文章?如果我要删除自动发布包,我需要做什么来呈现文章?
【问题讨论】:
标签: collections meteor handlebars.js meteorite