我们如何根据collection中的数据显示html字段?

How can we display html field based on the data in collection?

我是 meteor 的新手,我想检索 jenkins 作业并将该作业详细信息与参数一起存储在 mongoDB collection 中,然后显示不同的字段,例如文本框,选中按钮collection.
中的数据 我的工作collection

 db.jobs.find().pretty()
{
    "_id" : ObjectId("5a15bc45145a3789cb3b97eb"),
    "platform" : "xyz",
    "job_name" : "http://123.123.123.123:111/jobs",
    "a" : 0,
    "b" : 0,
    "c" : 0,
    "d" : 0,
    "e" : 0,
}

如您所见,我在 collection 中有此数据,对于 "job_name","platform" 我想要获取文本框,对于其他参数我想要复选框。
可能有很多工作,每个工作都应该有以上 属性.
joblist.html

<template name="jobs">
 <div id="listjobs">
  {{#each jobs}}
    ????how can i do it????
  {{/each}}
 </div>
</template>

我没写多少jspart.Please帮帮我

如果作业的返回值是一个对象,则如下所示

{
    "job": "job1",
    "job": "job2"
}

随便用

<form id="demo">
    {# for data in jobs #}
    <div id="listjobs">
        <input type="checkbox">{{ data.job }}
    </div>
    {# endfor #}
</form>

#each 块只是 for each 的包装器,当前文档在此块中变为 this。然后,您可以将数据与 this(如我下面的示例中所示)一起使用,或者仅通过 属性 名称引用。有关此内容的更多信息,请阅读 here in the Blaze documentation

作为预览:

<template name="jobs">
 <div id="listjobs">
  {{#each jobs}}
     <div>: {{this.job_name}}</div>
     <form id="form_{{this._id}}">
        <textarea name="platform">{{this.platform}}</textarea>
        <textarea name="job_name">{{this.job_name}}</textarea>
        <input type="checkbox" name="a">{{this.a}}
        <input type="checkbox" name="b">{{this.b}}
        <input type="checkbox" name="c">{{this.c}}
        <input type="checkbox" name="d">{{this.d}}
        <input type="checkbox" name="e">{{this.e}}
        <button type="submit">Submit</button>
     </form>
  {{/each}}
 </div>
</template>

请注意,您甚至可以在属性中使用上下文,如在表单 ID 中使用的那样。如果你想让你的复选框选中初始值,你需要这样做:

<input type="checkbox" name="e" checked="{{this.e}}">{{this.e}}