2 years ago

render some blade/variables with a function

Posted 2 years ago by nam_co

Hi, hope can help me, Im trying to render some blade with a function, but I can't seem to get it working

$attributes = array_merge(["class" => "form-control"], $attributes);
$string ='<div class="form-group form-group-default"><label for="{{$name}}">{{$label}}</label><input type="text" name="{{$name}}" id="{{$name}}" value="{{$value}}" {{$attributes}}></div>';
return \Blade::compileString($string, ['name' => 'hello_field','label' => 'Hello','value' => $value,'attributes' => $attributes]);

but this returns:

<div class="form-group form-group-default"><label for="<?php echo e($name); ?>"><!--?php echo e($label); ?--></label><input type="text" name="<?php echo e($name); ?>" id="<?php echo e($name); ?>" value="<?php echo e($value); ?>" <?php="" echo="" e($attributes);="" ?="">&gt;</div>

Appreciate any help

Please sign in or create an account to participate in this conversation.