Last active
September 19, 2015 04:47
-
-
Save mplatts/e1855a8f3630334aa557 to your computer and use it in GitHub Desktop.
templates - spacebar helpers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template name="headingWrapper"> | |
<h1>{{> UI.contentBlock}}</h1> | |
<h4>{{this.subheading}}</h4> | |
</template> | |
<template name="main"> | |
{{#headingWrapper subheading="My Subheading"}} | |
My Heading | |
{{/headingWrapper}} | |
</template> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment