appstract / laravel-blade-directives

A collection of nice Laravel Blade directives
MIT License
860 stars 75 forks source link

added @routestartswith #19

Closed stefro closed 7 years ago

stefro commented 7 years ago

Checks if the current route name starts with the provided string.

gizburdt commented 7 years ago

We discussed it, and we rather like the ability to pass a regex to the existing routeis directive. Could you build that?

stefro commented 7 years ago

In my opinion writing a regex as argument in the routeis is not that expressive. Since it would read like "Route is starts with" which doesn't make much sense when quick reviewing the code. Of course, I value your opinion of you won't merge this PR. It's still a great package :-)

teuunn commented 7 years ago

@stefro something like @routeis('blog.*') looks pretty readable (also when quick reviewing) to me.

stefro commented 7 years ago

@teuunn yes, that looks great! I didn’t get this from @gizburdt answer. I thought he wanted a regex as an argument. A wildcard would be nice!

gizburdt commented 7 years ago

I meant the same. A wildcard as parameter can be passed through a preg_match in directives.php, so all regexes are directly supported, not only a wildcard. Can you update this PR? Thanks for the help! :)

stefro commented 7 years ago

fnmatch makes it easy to allow for wildcards. I've just pushed an update.

gizburdt commented 7 years ago

Thanks :)