Handlebars:
Template
{{#each persons as | person |}}
    {{name}} lives in {{#with (lookup ../cities [resident-in])~}}
      {{name}} ({{country}})
    {{/with}}
{{/each}}
Preparation-Script
// Handlebars.registerHelper('loud', function(string) {
//    return string.toUpperCase()
// });
Input
{
  persons: [
    {
      name: "Nils",
      "resident-in": "darmstadt",
    },
    {
      name: "Yehuda",
      "resident-in": "san-francisco",
    },
  ],
  cities: {
    darmstadt: {
      name: "Darmstadt",
      country: "Germany",
    },
    "san-francisco": {
      name: "San Francisco",
      country: "USA",
    },
  },
}
Output
    Nils lives in Darmstadt (Germany)
    Yehuda lives in San Francisco (USA)
마지막 업데이트: 2024. 6. 5. 오후 11:37:24