I need to writte a function like this, but @asset
directive doesn’t work inside @php
. How can it be solved?
@php
$mpdf->WriteHTML(@asset('styles/single-pdf.css')), 1);
@endphp
I need to writte a function like this, but @asset
directive doesn’t work inside @php
. How can it be solved?
@php
$mpdf->WriteHTML(@asset('styles/single-pdf.css')), 1);
@endphp
\App\asset_path('styles/single-pdf.css')
So, is it like this?
@php
$mpdf->WriteHTML(\App\asset_path('styles/single-pdf.css'), 1);
@endphp
Have you tried it?
Just to expand on my answer a little, directives are essentially just an instruction to the Blade engine that says “Generate some PHP when you render this template,” so I’m pretty sure the it doesn’t try and parse them between @php
tags.
If you’re trying to find out what a Sage directive does, they’re defined in app/setup.php
.
Thank you very much! Yes, I Saw this directive in setup.php
. Also, its function on the helpers.php
function asset_path($asset)
{
return sage('assets')->getUri($asset);
}
And 'manifest' => get_theme_file_path().'/dist/assets.json',
And dist/assets.json
itself that contains all stored URIs with hashed names, if needed. I think is all related.