Last active
September 17, 2017 19:04
-
-
Save harikt/b5596b5d0aade1ab32afc162ebe82538 to your computer and use it in GitHub Desktop.
How to extend blade ? https://github.com/harikt/blade-renderer/pull/1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
How can we extend Blade ? | |
I am using the directive https://laravel.com/docs/5.5/blade#extending-blade | |
@url('article_show', ['id' => '3'], ['foo' => 'bar'], 'fragment') | |
Problem is the rest of the params after string `'article_show'` is not received on call back. | |
I am trying to do something similar to : https://zendframework.github.io/zend-expressive/features/template/twig/ | |
{{ path('article_show', {'id': '3'}) }} | |
which generates: /article/3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$urlHelperFactory = new UrlHelperFactory(); | |
$urlHelper = $urlHelperFactory($container); | |
$viewResolver->resolve('blade')->getCompiler()->directive('url', function ( | |
$routeName = null, | |
array $routeParams = [], | |
array $queryParams = [], | |
$fragmentIdentifier = null, | |
array $options = [] | |
) use ($urlHelper) { | |
// this works fine | |
return $urlHelper->generate('article_show', ['id' => '3'], ['foo' => 'bar'], 'fragment'); | |
// this breaks for the params are not received as expected. | |
// return $urlHelper->generate($routeName, $routeParams, $queryParams, $fragmentIdentifier, $options); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment