Closed marlongichie closed 7 years ago
Hey,
It's a silly mistake:
@set($some_variable, $model->someFunction())
transforms into
$some_variable = $model->someFunction(); $__data['some_variable'] = $model->someFunction();
should transform into
$some_variable = $model->someFunction(); $__data['some_variable'] = $some_variable;
in: Radic\BladeExtensions\Directives\SetDirective
class SetDirective extends AbstractDirective
{
protected $pattern = '/(?<!\w)(\s*)@NAME\s*\(\s*\${0,1}[\'"\s]*(.*?)[\'"\s]*,\s*([\W\w^]*?)\)\s*$/m';
protected $replace = '$1<?php \$$2 = $3; $__data[\'$2\'] = $3; ?>';
// which should actually be
protected $replace = '$1<?php \$$2 = $3; $__data[\'$2\'] = $2; ?>'; // (last $3 should be $2)
}
I'll release a patch soon. In the mean time you can use this fix. create: App/SetDirective.php
namespace App;
class SetDirective extends \Radic\BladeExtensions\Directives\SetDirective
{
protected $replace = '$1<?php \$$2 = $3; $__data[\'$2\'] = $2; ?>';
}
modify: config/blade-extensions.php
return [
'directives' => [
//'set' => 'Radic\\BladeExtensions\\Directives\\SetDirective',
'set' => 'App\\SetDirective',
// omited all the other stuff
]
];
@RobinRadic was this update included in v7.0
???
No,
I intend to have the next release include the changes for Laravel 5.5, as well as this fix. But i'm currently hold up by another project, so it might take another week or 2.
Until i release the next version, use the fix i mentioned in the previous reply.
As an alternative, you could define in your composer.json
{
"require": {
"radic/blade-extensions": "dev-master#ff39b0d7040dba11d57545452efd68d008779c76"
}
}
or
{
"require": {
"radic/blade-extensions": "dev-master#ff39b0d7040dba11d57545452efd68d008779c76 as 7.1.0"
}
}
When I used the
@set
directive like so :The
$model->someFunction()
is being called twice.If I replace the directive with standard PHP tags like so:
Everything works normal... the
$model->someFunction()
is called once as expected.Anyone else come across this issue?
Please advise.