Checking a null value in a meteor pattern
I use a meteorite. I have a template that looks like this:
<template name="SearchAct">
{{#each SearchPerson}}
<div class="result"><!--This is one search result box-->
<div class="resultContent">
<img src={{payload.pic_square}} alt="profile photo" class="floatLeft" />
<p>{{payload.uid}}</p>
<span class="floatLeft">
{{payload.first_name}}
<br/>
{{payload.last_name}}
</span>
<input type="checkbox" class="floatRight" />
<h4>Tennis</h4>
<span class="age_location">
{{#if payload.birthday}}
{{payload.birthday}},
{{/if}}
{{#if payload.sex}}
{{payload.sex}}
{{/if}}
<br/>
{{#if payload.hometown_location}}
{{payload.hometown_location.city}},
{{payload.hometown_location.state}},
{{payload.hometown_location.country}}
{{/if}}
</span>
<div class="line"></div>
<a href="#" class="clear" onclick="renderProfile({{payload.uid}});">See Their Details</a>
</div><!-- End of resultContent-->
</div><!-- End of result box-->
{{/each}}
</template>
Now I want to check the null value for {{payload.birthday}}. Here, if I get the value null, I want to display a message. How can I check the value null?
Handlebars (and Meteor extensions) do not allow logic inside templates. Therefore, you need to extend the template or all of your project templates with the Handlebars helper. Place the following in any client-loaded JavaScript file in your project:
Handlebars.registerHelper("isNull", function(value) {
return value === null;
});
if:
{{#if isNull payload.birthday}}Your birthday is null!{{/if}}
I think you can try this, you can use countif the birthdayeql value is 0 false, it works for me
<span class="age_location">
{{#if payload.birthday.count}}
{{payload.birthday}}
{{else}}
you display message
{{/if}}
</span>
ref: https://groups.google.com/forum/#!topic/meteor-talk/Gumkz9VnLYY