make cook-text async friendly

This commit is contained in:
Sam 2017-06-28 11:29:34 -04:00
parent bd7fbe6ad9
commit 301731ef24
1 changed files with 16 additions and 2 deletions

View File

@ -1,4 +1,18 @@
import { cook } from 'discourse/lib/text';
import { cookAsync } from 'discourse/lib/text';
import guid from 'pretty-text/guid';
import { registerUnbound } from 'discourse-common/lib/helpers';
registerUnbound('cook-text', cook);
function cookText(text) {
const id = `${guid().replace(/-/g, '')}`;
cookAsync(text)
.then(cooked => {
Em.run.next(()=>{
$('#' + id).html(cooked.string);
});
});
return new Handlebars.SafeString(`<div id='${id}'></div>`);
}
registerUnbound('cook-text', cookText);