Search code examples
javascriptjqueryhtmlckeditorjinja2

How do I stop CKEditor including HTML tags in content output?


In my flask-app I'm using CKEditor. This is my configuration so far.

In my layout.html at the end of the body tag:

<script src="//cdn.ckeditor.com/4.6.2/full/ckeditor.js"></script>
<script type="text/javascript">CKEDITOR.replace('editor')</script>

Here in my articles.html is the mentioned id for it:

<form action="" method="POST">
    <div class="form-group">
        {{ render_field(form.body, class="form-control", id="editor") }}
    </div>
    <p><input type="submit" class="btn btn-primary" value="Submit"></p>
</form>

This is how I am getting content back from my database when I write content using CKEditor CDN.

Screenshot of editor window showing Hello World, with HTML view below


Solution

  • Try this

    <form action="" method="POST">
                         <div class="form-group">
                             {{ render_field(form.body, class="form-control", id="editor") | safe }}
                         </div>
                         <p><input type="submit" class="btn btn-primary" value="Submit"></p>
                     </form>
    

    Reference