How to display data in blade laravel blade with html tag

688 views Asked by At

I am using a WYSIWG functionality in my application which works fine. And my problem now is in displaying its data in the user side. I'm trying to use {!! !!} but has no luck on making it work. This is my two data types the first one works with {!! !!} and the other one does not:

Works

<p><strong>Lorem</strong> ipsum dolor asdjfgjasfgbjgj
gjbhgjgjgjkghkj; lkfakj ;ljljfl sdfadfasfd asera
        <br>sdjfhgbkjhb jhgasfd <br><img src="https://instagram.fmnl4- 
4.fna.fbcdn.net/vp/9cc3e3163fa4c45e36ba06dab80a2a8b/5D0C4134/t51.2885- 
15/e35/52578723_295046217837106_4438462673106962420_n.jpg? 
_nc_ht=instagram.fmnl4-4.fna.fbcdn.net" height="500" width="500"></p> <br> 
jdsfa bygjhsdg jkbv kjbv lvkbsal lkjb nlknasdkfl lkjbokhbkldjskljbhjlkhkjhkl  
kjlkd aslkh l<br> jhasgdf jhdgywaegrhbkihn kjb klaSNDfckhb kjaghdfjbkjh 
<br>adsf knihlkh lk j ojlojjk <h1>fg lknhl kh lkuh adji3wij;oji voi npo ; 
posdjfopijnpaiywer <h1>

NOT

        <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
    <html><body><p><strong>Lorem</strong> ipsum dolor <strong>asdjfgjasfgbjgj </strong>gjbhgjgjgjkghkj; lkfakj ;ljljfl sdfadfasfd asera
                <br>sdjfhgbkjhb jhgasfd <br><img src="https://instagram.fmnl4-4.fna.fbcdn.net/vp/9cc3e3163fa4c45e36ba06dab80a2a8b/5D0C4134/t51.2885-15/e35/52578723_295046217837106_4438462673106962420_n.jpg?_nc_ht=instagram.fmnl4-4.fna.fbcdn.net" height="500" width="500"></p> <br><p> jdsfa bygjhsdg jkbv kjbv lvkbsal lkjb nlknasdkfl lkjbokhbkldjskljbhjlkhkjhkl  kjlkd aslkh l</p><p> jhasgdf jhdgywaegrhbkihn kjb klaSNDfckhb kjaghdfjbkjh </p><p>adsf knihlkh lk j ojlojjk </p><h1>fg lknhl kh lkuh adji3wij;oji voi npo ; posdjfopijnpaiywer </h1><h1></h1></body></html>

I parsed them this way:

{!! substr($new ->content, 0, 70) !!}

And there result is like this:

enter image description here

The second one is working in using the blade unescaped tag. I want them to be both displaying first 70 characters only. I'm using Laravel trumbowyg WYSIWG plugin. Someone know how to display it in blade php?

1

There are 1 answers

0
Ismail On

In order to by pass blade's limitations you should use @php @phpend and write your plain PHP code in there.