├── .gitignore ├── composer.json ├── src └── BladeMacroServiceProvider.php ├── LICENSE └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | vendor/ 2 | composer.lock 3 | composer.phar 4 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "grohiro/laravel-blade-macro", 3 | "version": "4.0.0", 4 | "description": "Laravel Blade `@macro` directive.", 5 | "keywords": ["laravel", "blade", "macro", "reusable-block"], 6 | "type": "helper", 7 | "license": "MIT", 8 | "homepage": "https://github.com/grohiro/laravel-blade-macro", 9 | "autoload": { 10 | "psr-4": { 11 | "Grohiro\\LaravelBladeMacro\\": "src/" 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/BladeMacroServiceProvider.php: -------------------------------------------------------------------------------- 1 | \n"; 15 | } 16 | }); 17 | 18 | \Blade::directive('endmacro', function ($expression) { 19 | return "\n\n"; 20 | }); 21 | } 22 | 23 | public function register() 24 | { 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 grohiro 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Laravel Blade Macro 2 | =================== 3 | 4 | - Available for Laravel 5.3+ 5 | - (also 5.0+, but not tested) (not working) (2017/10/3) 6 | 7 | LaravelBladeMacro creates a reusable template block in a blade template file. 8 | 9 | ## Usage 10 | 11 | form.blade.php 12 | 13 | ``` 14 | @macro('bootstrap_input', $type, $field, $label = "", $opts = ['class' => 'form-control']) 15 |
16 | 17 |
18 | {!! Form::$type($field, '', $opts) !!} 19 |
20 |
21 | @endmacro 22 | 23 | {!! Html::bootstrap_input('text', 'username', 'Username') !!} 24 | {!! Html::bootstrap_input('text', 'email', 'E-Mail', ['required' => 'required', 'class' => 'form-control']) !!} 25 | ``` 26 | 27 | ## Requirements 28 | 29 | - [Laravel Collective/HTML](https://laravelcollective.com/) for `Html` Facade. 30 | 31 | ## Install 32 | 33 | ```sh 34 | $ composer require 'grohiro/laravel-blade-macro' 35 | ``` 36 | 37 | config/app.php 38 | 39 | ```php 40 | $providers = [ 41 | // 42 | Grohiro\LaravelBladeMacro\BladeMacroServiceProvider::class, 43 | ]; 44 | ``` 45 | --------------------------------------------------------------------------------