gpt4 book ai didi

javascript - #each 上的 Handlebars 解析错误

转载 作者:数据小太阳 更新时间:2023-10-29 04:23:31 27 4
gpt4 key购买 nike

我正在返回以下 JSON 对象

{"status":"success",
"valmessage":"Your message has been sent successfully.",
"postcontent":{
"post_author":1,
"post_recipient":"1",
"post_title":"handle test 2",
"post_type":"wp_inbox_msg",
"post_content":"<p>giving it another go.<\/p>\n"},
"postmeta":{
"postid":410,
"postdate":"Monday, March 17th, 2014",
"author":"admin"},"replies":null,
"Formerrors":[]
}

我的 Handlebars 模板中出现以下错误:

Uncaught Error: Parse error on line 23:
...replies}} {{ #each replies }
----------------------^
Expecting 'ID', 'DATA', got 'INVALID'

在我的模板中我正在做以下事情:

        {{#if replies}}
{{ #each replies }}
<li>
<figure class="reply-author-img">
<img alt="" src="{{ avatar }}" height="96" width="96">
</figure>
<div class="replycontentwrap">
<div class="reply-from">
<p class="reply-author">
<strong>{{ fullname }}</strong>
<span>{{ nickname }}</span>
</p>
<span class="replydate">{{ reply_date }}</span>
</div>
<div class="reply-content">{{ reply_content }}</div>
</div>
</li>
{{ /each }}
{{/if}}

Replies 目前为 Null,但当有对消息的回复时它应该返回一组对象,最好的方法是如何 1) 让它工作和 2) 使用 handlebars.js 处理这种数据结构?

最佳答案

你得到的错误是因为你在'#each'和'/each'之前有一个空格,所以让它:

{{#each replies}}
/* each stuff */
{{/each}}

关于javascript - #each 上的 Handlebars 解析错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22466526/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com