I don't think it's possible to use both blade and mustache in the same file. How would any parser know {{ }} this one belongs to blade, but {{ }} this other one should be rendered by mustache
How can I user Mustache (or another option) with blade templates?
I have this example template file
// example.template
My name is {{ $name }} // I want to keep this braces
Company {{ $company }} // But this one I want to replace later
mustache file
$mustache = new Mustache_Engine;
$mustache->render('example.template', [
'company' => 'My Company'
]);
output
My name is
Company My Company
I don't want to do things like '$name' => '{{ $name }} cause I have so many routes with braces in my file that it would be terrible to write
Ok. So if I understand you correctly. You are generating *.blade.php files based on a stub file or something. Inside this generated blade.php file you want to have {{ $name }} variables. But you also want to enter some strings in your generated blade.php files. Am I seeing this correct?
If that is the case there is no need for a second parser I think.
If your stub files looks like this:
<div>
This is an auto generated blade file for model {{ $modelClass }} on {{ $createdOn }}<br />
The id of this model is @{{ $model->id }}
</div>
If you now create from this stub file a real blade file with pseudo code like:
$bladeContent = view()->make('path.to.stub', [
'modelClass' => \App\User::class,
'createdOn' => date()->format('Y-m-d H:i:s'),
])->render();
// if your stub is not in the view directory I think you can also use file() instead of make()
// save the generated content in your blade file on the location you want
At this moment your generated blade file should look like this:
<div>
This is an auto generated blade file for model \App\User on 2018-08-02 19:19:00<br />
The id of this model is {{ $model->id }}
</div>
Please or to participate in this conversation.