Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Checking null value in meteor template

I am using meteor. I have a template which 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 a null value for {{payload.birthday}}. Here if I get null value, I want to display a message. How could I check a null value?

like image 333
The lost Dev Avatar asked Jul 20 '12 13:07

The lost Dev


1 Answers

I think you just need an {{else}} in there:

<span class="age_location">
    {{#if payload.birthday}}
        {{payload.birthday}}
    {{else}}
        No birthday found
    {{/if}}
</span>
like image 92
ram1 Avatar answered Sep 30 '22 06:09

ram1