2

I am using CKeditor, and this is my code:

       ...othercode..


     <div class="input-field col s12">
                        <textarea id="textarea1" class="materialize-textarea"></textarea>
                        <label for="textarea1">Body of the Post</label>
                    </div>
                    <input type="submit" name="Submit" id="sub">
                </form>
            </div>
        </div>
    </div>
    {{else}}
    <div>You are not logged in.</div>
    {{/if}}
    <script>
    CKEDITOR.replace('textarea1');
    </script>

In Javascript, I use the same id to extract the text from the textarea, because I have to save it to collection. (Notice the handlebars.)

When I do that, It returns the html code, and that is saved as a string inside collection, and the handlebar doesnt do anythign and displayed the same html, without giving meaning to the html tags, i.e., just lame html.

How can this be converted to string anywhere, so that, the {{body}} handlebar shows exactly how it was typed inide CKeditor, and not what the backend of ckeditor returns.

This is the output I want:

Okay

Okay

Okay

THis is the output I get:

<p>Okay</p>
<p>Okay</p>
<p>Okay</p>
JAAulde
  • 19,250
  • 5
  • 52
  • 63
code
  • 2,115
  • 1
  • 22
  • 46

2 Answers2

3

You use triple braces in spacebars for this.

So your answer is

{{{body}}}
thatgibbyguy
  • 4,033
  • 3
  • 23
  • 39
  • This doesn't solve the issue. See the edited question. – code Jun 23 '15 at 12:35
  • 1
    Then you need to be more clear. To properly escape HTML coming from a template helper or data call you use triple braces. So be clear, are you simply trying to capture the data as html or are you trying to output it? You have the output part answered because that's what people think you are asking. – thatgibbyguy Jun 23 '15 at 12:39
1

Try it

<script>
function myFunction() {
  var iframe = document.getElementById("myFrame");
  var elmnt = iframe.contentWindow.document.getElementsByTagName("H1")[0];
  elmnt.style.display = "none";
}
</script>
Brandon Minnick
  • 13,342
  • 15
  • 65
  • 123
joeman
  • 11
  • 5