定制 jeroen-g/blade-macro 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

jeroen-g/blade-macro

最新稳定版本:1.1.0

Composer 安装命令:

composer require jeroen-g/blade-macro

包简介

Create small, file-specific, macros in Blade like Twig has.

README 文档

README

Latest Version on Packagist

Have you as a Laravel developer ever looked at Twig macros with envy?

Maybe you want to reuse a specific element twice on the same page, but you don't want to have it (supported) as a Blade component. With a Blade macro, you can. Here is an example:

@macro(listItem)
<li class="flex justify-center all-sorts-of-tailwind-classes"> {{ $name }} </li>
@endmacro

@if($conditionIsTrue)
    <ul>
        @foreach($listOne as $name)
            @showMacro(listItem, ['name' => $name])
        @endforeach
    </ul>
@else
    <ul>
        @foreach($listTwo as $name)
            @showMacro(listItem, ['name' => $name])
        @endforeach
    </ul>
@endif

Installation

Via Composer

$ composer require jeroen-g/blade-macro

Usage

Define a macro with the Blade directives:

@macro(myMacroName)
<fancy-code />
@endMacro

Call the macro elsewhere in the same Blade file with the Blade directive or PHP helper:

@showMacro(myMacroName)
// or
{!! m('myMacroName') !!}

Do you want to use a macro in another Blade view? Use a Blade component.

Change log

Please see the changelog for more information on what has changed recently.

Contributing

Please see contributing.md for details and a todolist.

Credits

License

MIT. Please see the license file for more information.

统计信息

  • 总下载量: 71
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 5
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 5
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-01-15

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固