[英]Async template preload with Nunjucks
Nunjucks使用getTemplate()預加載和預編譯模板-
env.getTemplate('page.html', true);
文檔還說:“如果使用任何異步加載程序,則必須使用異步API。” 但是沒有任何代碼示例。 誰能告訴我使用什么代替getTemplate進行異步預加載?
從他們的文檔中: Just add an async: true property to your loader and it will be used asynchronously.
https://mozilla.github.io/nunjucks/api.html#asynchronous
var MyLoader = nunjucks.Loader.extend({
async: true,
getSource: function(name, callback) {
// load the template
// ...
callback(err, res);
}
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.