2

Meteor v0.8.2 では、動的テンプレートによって呼び出される個々のテンプレート ( Template.story_en、 ) に対してヘルパーを作成する必要があるようです。Template.story_ne

以下の例のように、動的テンプレート ( Template.story) のみのヘルパーを作成し、動的テンプレートが使用できるすべての可能なテンプレートに対してヘルパーを繰り返さないようにすることは可能ですか? 私が使用している方法では、多くのコードを繰り返す必要があるようです。

ストーリー.html

<template name="story">
    {{> UI.dynamic template=storyTemplate}}
</template>

ストーリー.js

Template.story.storyTemplate = function() {
    return "story_" + Session.get('lang')
}


// This does not work
Template.story.color = function() {
    return '#f00'
}


// This works
Template.story_en.color = function() {
    return '#f00'
}

// This works (but seems to be unnecessary code)
Template.story_ne.color = function() {
    return '#f00'
}
4

1 に答える 1