Meteor Learning diary 1

  1. to build a new app     –meteor create name
  2.  spacebars: which includes  Inclusion, Expression, Block Helper


Here is one example,

Inclusion is in this format {{> templateName}}, which tells to Meteor we need another template  to show. In this case, we need postItem template.

Expression is {{title}}, similar as angular JS

Block Helper: is like small function, {{#each}}…{{/each}},{{#if}}…{{/if}}.

因为打中文快一些, 决定先打中文

添加基本的post列表模板和静态数据(Added basic posts list template and static data)


感觉,这是在用js冒充数据库, 不过数据是静态的. 其中重要的是添加helpers,也就是call function, 来让这个数据被引用。并且在Template.后面定义了postsList, 也就是定义此template的名字,也同时定义了helpers.

套路就是,用js 存放变量,冒充数据库,然后添加helpers来变成template,之后在html中直接引用此template即可。

在这回的tutorial中,一共有4个文件,包含上面的posts_list.js, 还有post_item.html, post_item.js, posts_list.html.


meteor 很像一环套一环,posts_list.html  通过 posts_list.js , 得到数据,并且以each的方式显示,并且引用template postItem, postItem.html,设计了数据该如何显示(即细节),最后main.html call template postLists. main->postList->postItem.



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s