I'm trying to compile and render a Dust template on the fly with nested partials from the client, but I keep getting "Error: Template Not Found: [templatePath]". The example shown below works if I use a child template that doesn't reference any partials (e.g. /templates/includes/childTemplate.dust), but not from a higher level main template (e.g. /templates/main.dust). Is there a way to pre-compile high level templates with child partials included?
var model = { ... };
$.get('/templates/main.dust', function(tpl) {
var compiled = dust.compile(tpl, 'mainTemplate');
dust.loadSource(compiled);
dust.render('mainTemplate', model, function(err, output) {
if (err) {
console.log(err);
}
$('#target').html(output);
});
});