dust-motes
dust-motes copied to clipboard
Bug when block contains async helper
I have a bug when i put an async helper in a block :
{@provide [optional params]}
main block of dust
{:block1}
{@myAsyncHelper /}
{/provide}
It causes a problem with render method...
Any idea ? Thanks in advance
Send me your async helper to allow more exploration if you can.
Below my helper ;)
dust.helpers.tr = function (chunk, context, bodies, params) {
var key = dust.helpers.tap(params.key, chunk, context);
var ns = dust.helpers.tap(params.ns, chunk, context);
var filter = dust.helpers.tap(params.filter, chunk, context);
if (!key){
return chunk.write('No translate key');
}
if (!ns){
return chunk.write('No namespace');
}
var locale = context.get('_locals.lng');
if (!locale){
return chunk.write('locale not found');
}
if (!i18n || !i18n.t){
return chunk.write('i18n not found');
}
return chunk.map(function(chunk){
i18n.t(locale, ns, key, params).then(function(value){
if (filter){
var filters = filter.split('|');
for(var filterItem in filters){
value = dust.filters[filters[filterItem]](value);
}
}
return chunk.end(value);
}).catch(function(err){
return chunk.end("");
});
});