在laravel中创建类似于section或yield的自定义刀片指令 [英] Create custom blade directive in laravel similar to section or yield

查看:91
本文介绍了在laravel中创建类似于section或yield的自定义刀片指令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为Bootstrap模型创建一个Blade指令,如下所示:

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

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

应该使用html生成完整的引导程序模型, 如何创建自定义的Blade指令以捕获html内容并对其进行处理?

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

推荐答案

我假设您的意思是引导程序模态"(如果我错了,请纠正我)...您可以尝试将其添加到您的AppServiceProvider boot()方法中

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;
    });

这篇关于在laravel中创建类似于section或yield的自定义刀片指令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆