Jaikar
Jaikar

Reputation: 31

Create custom blade directive in laravel similar to section or yield

I want to create a blade directive for bootstrap model something like below

@model('modelid')
   <div>Model body content</div>
@endmodel

Which should generate a complete bootstrap model in html, How to create a custom blade directive to capture the html content and process it?

Upvotes: 0

Views: 719

Answers (1)

aarcarr
aarcarr

Reputation: 186

Im assuming you mean bootstrap 'modal' (correct me if I'm wrong)... you could try adding this to your AppServiceProvider boot() method

 Blade::directive('modal', function ($modalid) {
       $html = '<some html utilising $modalid>'; 
       return $html;
    });

Upvotes: 1

Related Questions