简体   繁体   中英

How to display data in blade laravel blade with html tag

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:

在此处输入图片说明

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?

为了绕过 Blade 的限制,您应该使用 @php @phpend 并在其中编写您的纯 PHP 代码。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM