Created
March 25, 2014 04:43
-
-
Save majornorth/9755391 to your computer and use it in GitHub Desktop.
Game detail conditionals
This file contains 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="soloGameSummary"> | |
<div class="game-summary"> | |
{{#if organizing}} | |
<strong class="text-{{#if past startsAt}}muted{{else}}info{{/if}}"> | |
{{participle startsAt past='Organized' present='Organizing'}} | |
</strong> | |
{{else}} | |
{{#if playing}} | |
<strong class="text-{{#if past startsAt}}muted{{else}}info{{/if}}"> | |
{{participle startsAt past='Played' present='Playing'}} | |
</strong> | |
{{/if}} | |
{{/if}} | |
<strong>{{type}}</strong> {{> gameWhen}} | |
<div class="needed">{{#unless past startsAt}}{{numNeeded}} needed{{/unless}}</div> | |
<div class="place"> | |
<div class="place-name"> | |
{{placeName}} | |
</div> | |
<div class-"place-location">{{placeLocation}}</div> | |
</div> | |
<div class="organizer-info"> | |
{{#unless organizing}}Added by {{creator.name}}{{/unless}} | |
</div> | |
</div> | |
</template> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Each template has access to (1) its data context, (2) its helpers, and (3) "global" helpers.
The
soloGameSummary
template currently (as opposed to that in your gist) nests awhoIsPlaying
template that in turn has local helpersorganizing
,playing
, andnumNeeded
, which are defined indevel.js
via a call toTemplate.whoIsPlaying.helpers
.The
soloGameSummary
template does not itself define those helpers, so while it has access to a data context (which is a Game that has properties likestartsAt
andcreator.name
) and to "global" helpers (defined usingHandlebars.registerHelper
-- I have several defined inhandlebarsHelperMap
indevel.js
such aspast
andparticiple
), it does not have access to other templates' helpers.It seems like you may be itching to copy the helper-map argument passed to
Template.whoIsPlaying.helpers
and with it extend the argument currently passed toTemplate.soloGameSummary.helpers
. Note however that thewhoIsPlaying
template is currently used by both thelistedGameSummary
andsoloGameSummary
templates as an expression of commonality between those templates.