この非常にシンプルなアプリは機能していません。リストが表示されません。なんで?Meteorがどのように機能するかについて重要な何かを見逃しているに違いありません。
レシピ.html
<body>
<h3>Recipes</h3>
{{> recipes}}
</body>
<template name="recipes">
<ul>
{{#each recipes}}
<li>{{name}}</li>
{{/each}}
</ul>
</template>
レシピ.コーヒー
Recipes = new Meteor.Collection("recipes")
if Meteor.is_client
Meteor.startup ->
Meteor.autosubscribe(->
Meteor.subscribe('recipes')
)
# THIS IS NOT WORKING
Template.recipes.recipes ->
return Recipes.find()
if Meteor.is_server
Meteor.startup ->
if Recipes.find().count() == 0
data = [
name: "Chocolate Chip Cookies"
,
name: "Spring Rolls"
]
for item in data
Recipes.insert(item)
Meteor.publish('recipes', ->
return Recipes.find()
)
エラー
Uncaught TypeError: Object function (data) {
var getHtml = function() {
return raw_func(data, {
helpers: partial,
partials: Meteor._partials
});
};
var react_data = { events: (name ? Template[name].events : {}),
event_data: data,
template_name: name };
return Meteor.ui.chunk(getHtml, react_data);
} has no method 'recipes'
自動公開ありとなしでこれを試しました。ここで何がわからないのですか?
編集:
Jasdが指摘したように、私は以前に間違ったコードを投稿しました。現在のコードは問題のコードです。