templates - spacebar helpers
<template name="layout">
<div class="wrapper">
{{>nav}}
{{>yield}}
<div class="push"></div>
</div>
{{>footer}}
</template>
{{#each users}}
<li><a href="{{pathFor 'modulesList' username}}">{{username}}</a></li>
{{/each}}
{{#if currentUser}}
{{else}}
{{/if}}
{{#if loggingIn}}{{/if}}
UI.registerHelper('truncate', function(stringToShorten, maxCharsAmount){
if(stringToShorten.length > maxCharsAmount){
return stringToShorten.substring(0, maxCharsAmount) + '...';
}
return stringToShorten;
});
// Usage:
// {{truncate name 50}}
Template.registerHelper 'formattedDate', (timestamp, format) ->
moment(new Date(timestamp)).format(format)
// {{formattedDate createdAt "ddd, hA"}}
// => "Sun, 3PM"
// Note this requires package "momentjs:moment"
<template name="headingWrapper">
<h1>{{> UI.contentBlock}}</h1>
<h4>{{this.subheading}}</h4>
</template>
<template name="main">
{{#headingWrapper subheading="My Subheading"}}
My Heading
{{/headingWrapper}}
</template>