Home > Software design >  Laravel how to return css in function
Laravel how to return css in function

Time:09-11

So I have a function which I want to return this span class code

I already set the class code in my CSS

.subject{
   position:absolute;
   color: white;
   text-decoration: none;
   padding: 0px 25px 12px 0px;
   display: inline-block;
   border-radius: 2px;
}    

So my function created is this

function subject() {
return '<span ></span>';
}

I call the function like this in the blade

{{subject()}}

May I know why when I call the function it just return the code

'<span ></span>'; 

CodePudding user response:

After receiving on the blade, function contains HTML tag. Then you must use a single curly brace in each side and double exclamation marks on both side of the function call, and this is the most common ways of laravel not escaping HTML in the blade template:

{!!subject()!!}
  • Related