grohiro / laravel-blade-macro

Blade `@macro` directive
MIT License
14 stars 3 forks source link

Redundant bracket #1

Open kagan94 opened 7 years ago

kagan94 commented 7 years ago

Hi!

I've just installed this module and tried to test it, but it seems that you have an issue in Regex pattern because it parses unnecessary bracket which causes the error "**syntax error, unexpected ')', expecting

'{'**". Look at the results which were parsed: (The order is the following: $expression, $matches))

image

kagan94 commented 7 years ago

Probable solution might be $pattern = '/[\'"](\w+)[\'"],(.*)\)/';, but it needs to be checked and tested by someone.

grohiro commented 7 years ago

@kagan94 Thank you! I'm going to fix it soon.

grohiro commented 7 years ago

@kagan94 I could not see the error. Did you use macro like this?

@macro(('bootstrap_input', $smth = 1, $another_var = 9))

I think Blade directive may be used with a single parentheses.

@macro(...)
kagan94 commented 7 years ago

Hello. I wasn't lazy enough to install it again :).

In the instructions you use triple brackets, double brackets are enough (I guess it's just old blade style that they don't use any more): <label class="col-sm-1 control-label">{{{$label}}}</label>

I am using Laravel 5.2. I simplified the code:

@macro('bootstrap_input', $type, $field)
    Awesome! It's working :D
@endmacro
{!! Html::bootstrap_input('text', 'username') !!}

However, it produces the error "syntax error, unexpected ')', expecting '{'" in the view file. The error occurs because of producing extra, unnecessary, bracket:

image