Handlebars在#each上解析错误 - 如果 - 31:7,则每个都不匹配

时间:2017-06-13 18:47:08

标签: javascript jquery handlebars.js

我正在返回以下JSON对象

[{
"teamName": "foo",
"rallyLink": "foo",
"ttLink": "foo",
"featureName": "foo",
"managerAlias": "foo",
"description": "foo",
"managerName": "foo",
"simLink": "foo",
"pathname": "foo",
"teamAlias": "foo",
"environment": "foo",
"domain": "foo",
"host": "foo",
"cti": "foo",
"realm": "foo",
"id": "576e2781-38b8-46bd-85ed-7b862372cfa7"}]

我在我的车把模板中收到以下错误:

[WCM] renderJobData ERROR : Error: each doesn't match if - 31:7

在我的模板中我执行以下操作:

<style type='text/css'><!--
.table {font-size:small; font-family: verdana,arial,helvetica,sans-serif;  text-align:center; width:95%; border-color:#f4f4f4; border:3; border-collapse: collapse; }
.table td { padding:4; margin:0; border-color:#dddddd; border-style: solid; border-width:1px}
.tableCorner  { background-color:#F4F4F4 }
.rowHeader { font-weight:bold; font-size: x-small;  }
.row { font-size: x-small;  }
.columnHeader { font-weight:bold;  text-align:right; background-color:#F4F4F4; }
.header { font-weight:bold;  text-align:center; background-color:#F4F4F4; font-size: large;}
.labels { background-color:#F4F4F4; font-size: x-small; }
.text { background-color:#FFFFFF; font-size: x-small; }
--></style>
<div align='center'>
{{#if teamdata}}
    <table class='table'>
        <tbody>
            <tr class='header'>
                <td class='tableCorner'>&nbsp;</td>
                <td colspan=6><nobr>WHO CREATED ME</nobr></td>
                <td class='tableCorner'>&nbsp;</td>
            </tr>
            <tr class='rowHeader'>
                <td class='tableCorner'>&nbsp;</td>
                <td class='labels'><nobr>PROJECT NAME</nobr></td>
                <td class='labels'><nobr>DESCRIPTION</nobr></td>
                <td class='labels'><nobr>TEAM NAME</nobr></td>
                <td class='labels'>MANAGER NAME</td>
                <td class='labels'>REPORT AN ISSUE</td>
                <td class='labels'></td>
                <td class='tableCorner'>&nbsp;</td>
            </tr>
    {{#each teamdata}}
            <tr class='row'>
                <td class='tableCorner'>&nbsp;</td>
                <td class='text'><nobr>{{this.featureName}}</nobr></td>
                <td class='text'><nobr>{{this.description}}</nobr></td>
                <td class='text'><nobr><a href='mailto:{{this.teamAlias}}@amazon.com'>{{this.teamName}}</a></nobr></td>
                <td class='text'><nobr><a href='mailto:{{this.managerAlias}}@amazon.com'>{{this.managerName}}</a></nobr></td>
                <td class='text'><nobr>
                        {{if this.rallyLink}}
                                <a href='{{this.rallyLink}}'>Rally</a></nobr> |
                        {{/if}}
                        {{if this.simLink}}
                                <a href='{{this.simLink}}'>SIM</a></nobr> |
                        {{/if}}
                        {{if this.ttLink}}
                                <a href='{{this.ttLink}}'>TT</a></nobr> |
                        {{/if}}
                </td>
                <td class='text'><nobr></nobr></td>
                <td class='tableCorner'>&nbsp;</td>
            </tr>
    {{/each}}
            <tr class='rowHeader'>
                <td class='tableCorner'>&nbsp;</td>
                <td class='labels'><nobr> </nobr></td>
                <td class='labels'><nobr> </nobr></td>
                <td class='labels'><nobr> </nobr></td>
                <td class='labels'><nobr> </nobr></td>
                <td class='labels'><nobr><a href='https://amazon.com'>Submit creator deatails</a></nobr></td>
                <td class='labels'><nobr><a href='https://amazon.com'>Report an issue</a></nobr></td>
                <td class='tableCorner'>&nbsp;</td>
            </tr>
        </tbody>
    </table>
{{else}}
    <div>
        Unable to find Team Details.
    </div>
{{/if}}
</div>

我使用{{teamdata.0.id}}打印了teamdata我不明白什么是不匹配的?

1 个答案:

答案 0 :(得分:4)

您的{{if}}语句需要#

{{#if this.rallyLink}}