html - 检查 meteor 模板中的空值

标签 html templates meteor

我正在使用 meteor 。我有一个看起来像这样的模板,

<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>

现在我想检查 {{payload.birthday}} 的空值。在这里,如果我得到 null 值,我想显示一条消息。我如何检查 null 值?

最佳答案

我想你只需要一个{{else}}:

<span class="age_location">
    {{#if payload.birthday}}
        {{payload.birthday}}
    {{else}}
        No birthday found
    {{/if}}
</span>

关于html - 检查 meteor 模板中的空值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11580422/

相关文章:

c++ - std::list of boost::shared_ptr 的迭代器问题

c++ - 具有默认模板参数的参数包

javascript - 在 Meteor 中插入数千个文档

html - 如何在其正下方的元素上绘制CSS框阴影?

javascript - 使用 'like' 订购 <li> 元素?

html - 使用媒体查询构建响应式 UI

c++ - 获取模板类型的模板参数类型

meteor - meteor TDD 上的 Laika 与 Velocity

javascript - 使用 meteor-autoform 提交后创建文档

html - 表格行显示的图标图像和文本行不在同一行