https://github.com/grohiro/laravel-blade-macro
Blade `@macro` directive
https://github.com/grohiro/laravel-blade-macro
laravel laravel-5-package
Last synced: about 1 year ago
JSON representation
Blade `@macro` directive
- Host: GitHub
- URL: https://github.com/grohiro/laravel-blade-macro
- Owner: grohiro
- License: mit
- Created: 2014-06-18T14:06:26.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2017-10-03T09:23:12.000Z (over 8 years ago)
- Last Synced: 2025-05-06T04:03:13.262Z (about 1 year ago)
- Topics: laravel, laravel-5-package
- Language: PHP
- Size: 5.86 KB
- Stars: 14
- Watchers: 3
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Laravel Blade Macro
===================
- Available for Laravel 5.3+
- (also 5.0+, but not tested) (not working) (2017/10/3)
LaravelBladeMacro creates a reusable template block in a blade template file.
## Usage
form.blade.php
```
@macro('bootstrap_input', $type, $field, $label = "", $opts = ['class' => 'form-control'])
{{$label}}
{!! Form::$type($field, '', $opts) !!}
@endmacro
{!! Html::bootstrap_input('text', 'username', 'Username') !!}
{!! Html::bootstrap_input('text', 'email', 'E-Mail', ['required' => 'required', 'class' => 'form-control']) !!}
```
## Requirements
- [Laravel Collective/HTML](https://laravelcollective.com/) for `Html` Facade.
## Install
```sh
$ composer require 'grohiro/laravel-blade-macro'
```
config/app.php
```php
$providers = [
//
Grohiro\LaravelBladeMacro\BladeMacroServiceProvider::class,
];
```