Listing posts
Now that we have walked through all ways of using helpers and data, I want to introduce a block helper named {{#each}}
, which we will probably find the most useful.
If we go through all the examples completed up to now, we can see that it is better to delete all the examples of data context from our home
template, the examples.html
file, and its examples.js
JavaScript file so that we can continue to build our blog cleanly.
The next step is to add a list of blog entries to our home page. For this, we need to create a template for a post preview. This can be done by performing the following steps:
We create a file called
postInList.html
in ourmy-meteor-blog/client/templates
folder and save it with the following code snippet:<template name="postInList"> <div class="postListItem"> <h2><a href="#">{{title}}</a></h2> <p>{{description}}</p> <div class="footer"> Posted by {{author}} </div> </div...