简体   繁体   English

车把的正确路径

[英]handlebars correct path for lookup in each

I'm trying to do a lookup in an each block, but it's not rendering anything, which leads me to believe it's undefined. 我正在尝试在每个块中进行查找,但未呈现任何内容,这使我认为它是未定义的。 I'm wondering if I have the path wrong. 我想知道我的路径是否错误。

Does the path start from the top level of the each, or the bottom? 路径是从每个层的顶部还是从底部开始?

{{#each totals.mapped_total.roo}}
    <div class="data_box>
        <span>Month {{ @index }}</span>
        <span class="mapped_vals">{{ this }}</span>
        <span class="unmapped_vals" style="display:none">
            {{#with (lookup ../../unmapped_total.roo @index)}}
                {{value}}
            {{/with}}
        </span>
    </div>
{{/each }}

Here's what the data looks like: 数据如下所示:

totals = {
u'unmapped': 0,
u'unmapped_total': {u'mdown': 0, u'rec_retail': 0, u'roo': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], u'inv': 0, u'sales': 0, u'rec_cost': 0, u'inv_fom': 0, u'tfrin': 0, u'mup': 0, u'tfrout': 0, u'venret': 0, u'coo': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]},
u'mapped_total': {u'mdown': 13, u'rec_retail': 29, u'roo': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], u'inv': 115, u'sales': 16, u'rec_cost': 12, u'inv_fom': 0, u'tfrin': 0, u'mup': 0, u'tfrout': 0, u'venret': 308, u'coo': [33, 17, 2, 1, 3, 11, 8, 8, 0, 0, 0, 0]},
u'mapped': 15}

One final challenge, no helpers. 最后的挑战,没有帮助者。 Must do this out of the box. 必须开箱即用。

The end goal is to toggle between mapped and unmapped. 最终目标是在映射和未映射之间切换。

Here's what I used that works: 这是我使用的有效方法:

{{#each totals.mapped_total.roo}}
<div class="data_box">
    <span class="month_label">>Month {{ @index }}</span>
    <span class="mapped_vals">{{ this }}</span>
    <span class="unmapped_vals" style="display:none">
        {{lookup ../totals.unmapped_total.roo @index}}
    </span>
</div>
{{/each }}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM