将空格参数传递给另一个空格参数

Pass spacebar parameter to another spacebar parameter

本文关键字:空格 参数 另一个 参数传递      更新时间:2023-09-26

我试图在meteor.js中从一个模板传递参数到另一个模板我想干这个缘故第一个模板看起来像这样

template(name="myPage") 
   h3.uppercase.amarillo-hogar 
      +editaMl(data=this collection="categorias" field="titulo")
template(name="editaMl")
        if i18n_isCurrentLanguage 'es'
            | {{collection}} {{field}}
            +editableText(context=data collection=collection field=field userCanEdit=userCanEdit acceptEmpty=true substitute='<i class="fa fa-pencil"></i>')
        else 
            +editableText(collection=collection field=field userCanEdit=userCanEdit acceptEmpty=true substitute='<i class="fa fa-pencil"></i>')

这样我就不用在每个翻译字段重复自己了但是不能将参数值传递给另一个模板参数值

我用翡翠,现在在HTML中为那些不喜欢翡翠的人

<template name="myPage">
    <h3 class="uppercase amarillo-hogar>{{> editaMl collection="categorias" field="titulo"}}</h3>
</template
<template name="editaMl">
    {{#if i18n_isCurrentLanguage 'es'}}
        {{> editableText collection=collection field=field }}
    {{/if}}
    {{#else}}
        {{> editableText collection=collection field=field }}
    {{/else}}
</template>

只是如果你想知道,我使用babraham可编辑文本包和tap_i18n tap_i18n UI来翻译

找不到我的助手返回对象的原因,当在内容{{collection}}中这样使用时,但当在子模板中用作参数时,什么也不做

Code updated and SOLVED

您可以使用:

Template.registerHelper('yourHelperName', function() {
   // your helper
});

创建一个在所有模板中可用的帮助器