2017 © Pedro Peláez
 

library blademacro

add macro to blade laravel

image

rtler/blademacro

add macro to blade laravel

  • Monday, August 17, 2015
  • by RTLer
  • Repository
  • 1 Watchers
  • 2 Stars
  • 4 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

bladeMacro

macro extension for laravel blade. it add macros to laravel blade that work just like html macro but there is problem with html macro that it register and echo function into compiled view code and run functin every time page loads, but this library run fubction and echo return into compiled view., (*1)

installation

add this to your providers, (*2)

    'providers' => [
        ...
        RTLer\BladeMacro\BladeMacroServiceProvider::class
        ...
    ],

usage

and register macroes using(for adding php code to view write it in string), (*3)

      BladeMacro::macro('inputText', function ($arg1, $arg2, $arg3, $arg4) {
          return 'testing ' . $arg1 . ' ' . $arg2 . ' ' . $arg3 . ' ' . $arg4;
      });

*it can contains php code in return string, (*4)

and in view use it like this (macroName(arg1, arg2, ...)):, (*5)

    @macroInputText('name', 'value', 'label', 'options')

and becuse of that this code replase the return string of the BladeMacro::macro function and cache it, after changeing the macro run the command, (*6)

php artisan view:clear

contribute

i add Illuminate\Html to it (htmlName(arg1, arg2, ...),formName(arg1, arg2, ...)) but there is problem with form if you like to help fix form., (*7)

The Versions

17/08 2015

dev-master

9999999-dev

add macro to blade laravel

  Sources   Download

GPL2

The Requires

 

by hooman naghiee