All my Dustjs templates are kept precompiled in a database. To render the template I have this function
tmplfn(options, function (err, html) {
res.write(html); //res is the response object
res.end();
});
But this fails when the templates have got partials in it because it is not able to locate the partial. How can I resolve this issue? Is there any mechanism to register my partial with the dustengine?
I'm not familiar with dust.js myself, but according to the docs :
dust.onLoad(name, callback(err, out))
By default Dust returns a "template not found" error when a named template cannot be located in the cache. Override
onLoad
to specify a fallback loading mechanism (eg, to load templates from the filesystem or a database).
This seems to me like a good starting point.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.