Reputation: 2503
I am using CKeditor for my Laravel 5.1 custom CMS. When I request content of stored pages in the database on my view, they appear with HTML tags like <p>Hello world</p>
.
I have used html_entity_decode()
with and without the charset specified to no avail.
It is also worth mentioning that I use Blade template engine at my view. Hence, my demo code looks like
$post->content = '<p>Hello world</p>'; // from the database from controller
{{html_entity_decode($post->content)}} //did not decode
I also tried using it in my controller instead and it did not change anything like this
$post->content = html_entity_decode($post->content); //before sending it to the view
I need your help to address this issue.
Upvotes: 4
Views: 6699
Reputation: 316
you can do this in the controller
strip_tags($post->content);
or if you use in blade
{{ strip_tags( $post->content ) }}
see more info here strip_tags
Upvotes: 0
Reputation: 6625
Instead of doing {{html_entity_decode($post->content)}}
,
try this:
{!! $post->content !!}
More info here https://laravel-news.com/2014/09/laravel-5-0-blade-changes/
Upvotes: 7