Pass multiple parameters to a blade directive

前端 未结 9 1752
时光说笑
时光说笑 2021-02-19 07:31

I\'m trying to create a blade directive to highlight some words that will return from my search query.

This is my blade directive:

class AppServiceProvid         


        
9条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-19 07:40

    Blade::directive('highlight', function($arguments){
    
            list($arg1, $arg2) = explode(',',str_replace(['(',')',' ', "'"], '', $arguments));
    
            $expressionValues = preg_split('/\s+/', $arg1);
    
            $output = "";
    
            foreach ($expressionValues as $value) {
                $output .= str_replace($value, "".$value."", $arg2);
            }
    
            return "";
        });
    

提交回复
热议问题