CKeditor 输出 Html。如何格式化它以正确显示,而不仅仅是蹩脚的 html?

CKeditor outputs Html. How to format it for displaying properly, not just lame html?

我正在使用 CKeditor,这是我的代码:

       ...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>

在Javascript中,我使用相同的id从textarea中提取文本,因为我必须将其保存到集合中。 (Notice the handlebars.)

当我这样做时,它 returns html 代码,并在集合中保存为字符串,车把不做任何事情并显示相同的 html,没有赋予 html 标签意义,即,只是蹩脚的 html.

如何在任何地方将其转换为字符串,以便 {{body}} 控制栏准确显示它在 CKeditor 中的输入方式,而不是 ckeditor 的后端 returns.

这是我想要的输出:

Okay

Okay

Okay

这是我得到的输出:

<p>Okay</p>
<p>Okay</p>
<p>Okay</p>

为此,您在空格键中使用三重大括号。

所以你的答案是

{{{body}}}

试一试

<script>
function myFunction() {
  var iframe = document.getElementById("myFrame");
  var elmnt = iframe.contentWindow.document.getElementsByTagName("H1")[0];
  elmnt.style.display = "none";
}
</script>