小胡子部分不循环传递给它的数据

mustache partial not looping through the data passed down to it

我正在使用 mustache in conjunction with enter link description herepattern lab 从 json 数据文件中呈现项目列表。鉴于此数据结构:

{
  "states": {
    "dropdown": {
      "items": [
        {
          "title": "CA"
        },
        {
          "title": "OR"
        },
        {
          "title": "TX"
        }
      ]
    }
  },
  "roles": {
    "dropdown": {
      "items": [
        {
          "title": "Mid-level Office Manager"
        },
        {
          "title": "Facility Manager"
        },
        {
          "title": "Resources Coordinator"
        }
      ]
    }
  }
}

如果我在部分中执行以下操作:

{{#states}}
  {{#dropdown.items}}{{title}}{{/dropdown.items}}
{{/states}}

名称呈现得很好。

但是如果我这样做:

{{#states}}
  {{> molecules-dropdown-picker(btnDropdownToggleLabel: "OR")}}
{{/states}}

下拉选择器部分具有以下代码:

{{#dropdown.items}}{{title}}{{/dropdown.items}}

它不会呈现。我做错了什么?

我通过执行以下操作解决了这个问题:

JSON:

{
  "states": {
    "inputTextLabel": "State",
    "inputTextName": "address_state",
    "btnDropdownToggleLabel": "OR",
    "dropdownPickerItems": [
      {
        "dropdownItemTitle": "OR"
      },
      {
        "dropdownItemTitle": "TX"
      },
      {
        "dropdownItemTitle": "UT"
      }
    ]
  },
  "roles": {
    "inputTextLabel": "Company Role",
    "inputTextName": "company_role",
    "btnDropdownToggleLabel": "Facility Manager",
    "dropdownPickerItems": [
      {
        "dropdownItemTitle": "Facility Manager"
      },
      {
        "dropdownItemTitle": "Resources Manager"
      },
      {
        "dropdownItemTitle": "Mid-level Manager"
      }
    ]
  }
}

表格:

{{#states}}
  {{> molecules-dropdown-picker-list}}
{{/states}}

下拉选择器列表:

<div class="dropdown-picker js-dropdown">
  <ul class="dropdown-picker__list js-dropdown-list">
    {{#dropdownPickerItems}}
      {{> atoms-dropdown-picker-item}}
    {{/dropdownPickerItems}}
  </ul>
</div>

下拉选择器项目:

<li class="dropdown-picker__item js-dropdown-item">
  {{dropdownItemTitle}}
  <span class="dropdown-picker__selected-check">
    {{> atoms-icon(icon-type: "check-small") }}
  </span>
</li>