Skip to content Skip to sidebar Skip to footer

Display Pure Html Code In Tinymce Laravel

Hi I am using tinmymce in laravel5. I create blogposts where i need to display code snippets. for example i want to display this bit of code snippet Copy

this will echo the value for Html engine and Tinymce

Don't use:

{{$variable}}

Solution 2:

I've spent half a day trying to solve it and finally I've figured out that here is the problem with textarea and Blade, not with tinyMCE. If you are using something like

<textarea calss="js-wysiwyg">
{{ $blog->text }}
</textarea>

and the blog text contains some html tags like <pre>, <input> or <form>, textarea will do a bit of magic with it and after tinyMCE initializing you will end up with very strange output (nothing outputted in your case and rendered html input in mine :) ). So, you have 2 different options:

<textarea calss="js-wysiwyg">
{{ htmlentities($blog->text) }}
</textarea>

or

<div contenteditable="true" calss="js-wysiwyg">
{{ $blog->text }}
</div>

Variant with htmlentities is better because you don't need to create some jQuery solution for passing value of the div in request (because divs don't have 'name' attributes) Hope this will help someone!

Post a Comment for "Display Pure Html Code In Tinymce Laravel"