2015-10-21 60 views
1

我試着從一個模板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爲翻譯

不能找到的內容像這樣使用的時候幫助我返回一個對象的原因{{收集}}但作爲參數子模板使用時不做任何

代碼更新,解決

+0

'collection = collection field = field' should not work should not it?但是'en.field'不會,您需要從父級傳入英文字段名稱。 –

+0

我也一樣,實際上是這樣寫的,不工作 即時通過模板中的空白條只是爲了看到解析信息,它解析它,但沒有工作,當我嘗試重用第二個參數中的參數 –

+0

可能嘗試'this.collection'和'this.field' –

回答

0

您可以使用:

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

它在所有模板中創建一個助手。

+0

不錯,謝謝! –