Asynchronous support for nunjucks.addGlobal

229 views
Skip to first unread message

Shawn Lim

unread,
Feb 5, 2015, 4:40:05 AM2/5/15
to nunj...@googlegroups.com
I need nunjucks global functions to be able to work with asynchronous functions. My use case is to fetch translation information. 

Something like this doesn't seem to work: 

nunjucks_env.addGlobal('gettext', function(key){
 
var d = $.Deferred();


  setTimeout
(function(){
    d
.resolve('hurray');
 
}, 2000);  


 
return d.promise();
});



Lasana Murray

unread,
Feb 13, 2015, 9:51:15 AM2/13/15
to nunj...@googlegroups.com
As far as I can tell nunjucks does not support promises. Can you use an async filter or extensions instead?

http://mozilla.github.io/nunjucks/api.html#asynchronous1
Reply all
Reply to author
Forward
0 new messages