Thanks. That's actually more of a hack though, because you will doing two requests per page load.
Although that will work, I think the better solution is more complex.
You'll want to hook into the controller filter for the page in which you want the additional template, and append the new data for rendering. If you are importing a template that has any variables with the same name in the base template, you'll need to create a new template that has the additional data namespaced.
e.g.
your library.js
var Theme = module.exports = {};
var topics = require.main.require('./src/topics');
// filter:topic.build
Theme.topicBuild = function(data, next){
topics.getTopicsFromSet('topics:recent', data.req.uid, 0, 5, function(err, recentData) {
data.templateData.recent = recentData;
next(null, data);
});
};
add to your topics.tpl
<!-- IMPORT recentembed.tpl -->
in recentembed.tpl, copy recent.tpl but prefix the variables with your recent
namespace
<!-- BEGIN recent.topics -->
{recent.topics.title}
<!-- END recent.topics -->
There may be a way to explicitly declare the namespace too that I'm not aware of, something like
<!-- IMPORT recent.tpl USING recent -->
which would eliminate the need for an additional template if it exists.