I would like to print out BBCode for text on a profile page, which is written by users. I’m using bbob by JiLiZART.
The written text is saved inside the users-document but I have trouble figuring out how I can render the text before it’s actually displayed on the page.
<p id="chardescBB" style="white-space: pre-line"> {{char.chardesc}} </p>
This is where the written text would be displayed.
Now on this template I use
Template.c.onRendered(function () {
Meteor.setTimeout(function(){
const desc = document.getElementById("chardescBB");
code = desc.innerHTML;
const html = bbob(presetHTML5()).process(code, { render }).html;
document.getElementById("chardescBB").innerHTML = html;
}, 500);
});
to render this text. But this solution is terrible. If the page gets rendered it first shows [b]text[/b] and after 500ms to text due to the Timeout I have to use because it won’t find the value of the displayed right away.
Question would be, if someone could tell me the proper way to do it with blaze? Is the whole approach wrong?