Trouble displaying data from a WYSIWG editor


#1

First of all I’m not sure I’m doing this the right way, so please tell me if there is some different, better method.

I’m using a WYSIWYG editor to store some data into a collection, something like this:
someData: "<p>This </p> <span>is a</span> <p>test</p>"

Then in my template I have this:

<div class="test"> {{formatHTML someData}} </div>

And in my JS file i have this function:

UI.registerHelper("formatHTML", function(data) {
     
        return $(".test").html(data);

    });

But what i got returned instead of <p>This </p> <span>is a</span> <p>test</p> is [object Object].

I’ve tried substring() to remove the “” but that can’t remove them.

Thx in advance!


#2

You are returning a jQuery function call which is why you are getting an object. The way I would do this is use 3 curly braces as this formats data as html in templates rather than text, so change {{formatHTML someData}} to {{{ someData }}}


#3

Thanks man!!
Exactly what I was looking for, didn’t know there were triple braces in meteor :open_mouth: