Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

CookieMonster's avatar

Laravel- blade how to output HTML tag in double curly braces?

I am using laravel-share package and the code is supposed to look like this:

<div>
        {{Share::page('www.google.com')->facebook()}}
 </div>

It is supposed to translate to this in HTML tags where it displays a facebook icon:

<div id="social-links">
 <ul>
 	<li>
 		<a href="https://www.facebook.com/sharer/sharer.php?u=www.google.com" class="social-button " id="" 				 
 title="">
 <span class="fab fa-facebook-square"></span>
 		</a>
 	</li>
 </ul>
</div>

However, in my browser, it does not display the icon and instead displays the HTML texts(same as above):

How do I ensure it output the icon instead?

0 likes
5 replies
Nakov's avatar

@nickywan123 you need to use {!! !!} syntax to escape the encoding. But make sure the content that you get is safe to do so.

        {!! Share::page('www.google.com')->facebook() !!}
1 like
CookieMonster's avatar

Thanks, but what is the security issues that can go wrong with this?

CookieMonster's avatar

i switched to this way:

 <a href="https://www.facebook.com/sharer/sharer.php?u={{url()->current()}}" target="_blank"><span class="fab fa-facebook-square fa-3x pr-2" style="color:#3b5998"></span></a>

Is it better?

ftiersch's avatar

Use unfiltered output if you're sure about the source:

{!! !!}

Please or to participate in this conversation.