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
如何引用Meteor中不同模板的不同子模板?_Meteor_Spacebars - Fatal编程技术网

如何引用Meteor中不同模板的不同子模板?

如何引用Meteor中不同模板的不同子模板?,meteor,spacebars,Meteor,Spacebars,我有5个模板。两个模板调用一个模板,然后根据调用它的模板调用另两个模板 我想做以下工作: <template name="Template1"> <!-- show his things --> {{BaseTemplate SubTemplate1}} </template> <template name="Template2"> <!-- show his things --> {{BaseTemplate

我有5个模板。两个模板调用一个模板,然后根据调用它的模板调用另两个模板

我想做以下工作:

<template name="Template1">
   <!-- show his things -->
   {{BaseTemplate SubTemplate1}}
</template>

<template name="Template2">
   <!-- show his things -->
   {{BaseTemplate SubTemplate2}}
</template>

<template name="BaseTemplate">
   {{#each xpto}}
     <!-- show base things -->
     {{BaseTemplate {{CallSubTemplateGiven}} }}
   {{/each}}
</template>

<template name="SubTemplate1">
   <!-- show few things -->
</template>

<template name="SubTemplate2">
   <!-- show other things -->
</template>

{{BaseTemplate子模板1}}
{{BaseTemplate子模板2}}
{{{#每个xpto}
{{BaseTemplate{{CallSubTemplateGiven}}}
{{/每个}}

有办法吗?无法理解如何使用RegisterHelper执行此操作。

您应该能够通过将子模板作为参数传递给基础模板,然后使用template.dynamic呈现正确的模板来执行此操作

 <template name="Template1">
               {{> BaseTemplate subtemplate=SubTemplate1 }}
</template>

<template name="Template2">
               {{> BaseTemplate subtemplate=SubTemplate2 }}
</template>

<template name="BaseTemplate">
    {{#each xpto}}
               {{> Template.dynamic template=../subtemplate }}
    {{/each}}
</template>

<template name="SubTemplate1">

</template>


<template name="SubTemplate2">

</template>

{{>BaseTemplate子模板=子模板1}
{{>BaseTemplate子模板=SubTemplate2}
{{{#每个xpto}
{{>Template.dynamic Template=../subtemplate}
{{/每个}}

应该是
{>Template.dynamic Template=../subtemplate}
,因为
#每个
中的上下文都会发生变化,这真是神奇!谢谢你们两位给我小费。我在Meteopad上编写了一个简单的测试应用程序来展示它。我希望我以正确的方式分享它:[链接]()