Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/meteor/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/40.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
模板参数中的Meteor-Pass变量_Meteor_Meteor Blaze_Spacebars - Fatal编程技术网

模板参数中的Meteor-Pass变量

模板参数中的Meteor-Pass变量,meteor,meteor-blaze,spacebars,Meteor,Meteor Blaze,Spacebars,我正在尝试这样做: <template name=week> {{#each days}} //from an array in helpers with values [0,1,2,3,4,5,6] {{> day dayOfWeek="<How can I have the value here?>"}} {{/each}} <template name> {{{#each days}}//从值为[0,1,2,3,4,5,

我正在尝试这样做:

<template name=week>
   {{#each days}} //from an array in helpers with values [0,1,2,3,4,5,6]
      {{> day dayOfWeek="<How can I have the value here?>"}}
   {{/each}}
<template name>

{{{#each days}}//从值为[0,1,2,3,4,5,6]的helpers中的数组
{{>day dayOfWeek=”“}
{{/每个}}
问题1:如何检索数组的当前值以将其传递给包含的模板

<template name=day>
   {{#autoForm collection=users doc=user ...}}
      {{#each days}} //from an array in helpers with values [0,1,2,3,4,5,6]
         {{>afFieldInput name='profile.availability.<dayOfWeek>.from'}}
      {{/each}}
   {{/autoForm}}
<template name>

{{{#autoForm collection=users doc=user…}
{{{#each days}}//从值为[0,1,2,3,4,5,6]的helpers中的数组
{{>afFieldInput name='profile.availability..from'}
{{/每个}}
{{/autoForm}
问题2:如何在名称中动态替换dayOfWeek?

尝试以下方法:

问题1:

<template name="week">
  {{#each days}} //from an array in helpers with values [0,1,2,3,4,5,6]
    {{> day dayOfWeek=this}}
  {{/each}}
<template name>

注意:这是使用Meteor 1.2最新的Blaze构造和ES2015,谢谢。除了中的${dayOfWeek}profile.availability之外,它还能工作;。我不得不用“profile.availability.”+dayOfWeek+“.to”来代替。是因为我还没有使用1.2吗?是的,模板字符串语法是ES2015的一项新功能,从Meteor 1.2开始提供
<template name="day">
  {{#autoForm collection=users doc=user ...}}
    {{#each day in days}} //from an array in helpers with values [0,1,2,3,4,5,6]
      {{> afFieldInput name=name}}
    {{/each}}
  {{/autoForm}}
<template name>
Template.day.helpers({
  name(){
    const dayOfWeek = this.dayOfWeek;
    return `profile.availability.${dayOfWeek}.from`;
  }
});