2014-01-31 29 views
2

如何在Meteor JS中加载多个模板?我知道如何动态加载一个模板。但没有得到加载多个模板。请参阅加载单个模板的下面的代码&建议我如何加载多个模板?在Meteor JS中动态加载多个模板?

JS代码:

Meteor.startup(function() 
    { 
    Session.set('currentTemplate', 'login'); 
    }); 
Template.content.helpers 
({ 
    'renderTemplate': function() 
    { 
     if(Session.get('currentTemplate') == undefined) 
     { 
     Session.set('currentTemplate', 'login'); 
     } 
     return new Handlebars.SafeString(Template[Session.get('currentTemplate')]({dataKey: '0'})); 
    } 
}) 
+0

您可能需要考虑使用[router](https://github.com/EventedMind/iron-router)。 –

回答

1

要加载中另一个模板:

<template name="oneTemplate"> 
    {{> anotherTemplate}} 
</template> 

要加载根据URL不同的模板,最好使用Iron Router