Handlebarjsを使用して、配列をループし、区切り文字で区切って値を表示したいと思います。表示したいコンテンツもテンプレートでなければ簡単です;)
これが私の場合です:
accounts = [
{'name': 'John', 'email': 'john@example.com'},
{'name': 'Malcolm', 'email': 'malcolm@example.com'},
{'name': 'David', 'email': 'david@example.com'}
];
{{#each accounts}}
<a href="mailto:{{ email }}" title="Send an email to {{ name }}">{{ name }}</a>,
{{/each}}
この実装の問題は、次の出力が得られることです。
ジョン、マルコム、デビッド、
そして、私はそれをしたいです:
ジョン、マルコム、デビッド
どうやってやるの ?