Skip to content
Permalink
Browse files

Added pluralize helper to format text better.

chapter13-3
  • Loading branch information
tmeasday committed Oct 19, 2015
1 parent a694341 commit 1480289e2ef03b9d84fbaf5e607d71c0ccb49b1f
Showing with 10 additions and 2 deletions.
  1. +8 −0 client/helpers/handlebars.js
  2. +2 −2 client/templates/posts/post_item.html
@@ -0,0 +1,8 @@
Template.registerHelper('pluralize', function(n, thing) {
// fairly stupid pluralizer
if (n === 1) {
return '1 ' + thing;
} else {
return n + ' ' + thing + 's';
}
});
@@ -4,9 +4,9 @@
<div class="post-content">
<h3><a href="{{url}}">{{title}}</a><span>{{domain}}</span></h3>
<p>
{{votes}} Votes,
{{pluralize votes "Vote"}},
submitted by {{author}},
<a href="{{pathFor 'postPage'}}">{{commentsCount}} comments</a>
<a href="{{pathFor 'postPage'}}">{{pluralize commentsCount "comment"}}</a>
{{#if ownPost}}<a href="{{pathFor 'postEdit'}}">Edit</a>{{/if}}
</p>
</div>

0 comments on commit 1480289

Please sign in to comment.
You can’t perform that action at this time.