我正在使用 Wordpress 框架 Sage,它与 Blade 模板捆绑在一起。 Sage 有一个名为 @asset
的自定义指令,它返回 Assets URL。例如@assets('images/my-image.jpg')
。
我想在 @include
内部使用该指令。可能吗?
例如,我希望它能工作,但它返回一个错误,指出 @asset
是一个未定义的函数,但它在 @include
之外工作正常:
@include('partials/components/hero', ['data' => [
'heading' => 'Hero heading example from pattern library',
'subtitle_1' => 'Hero subtitle example from pattern library',
'subtitle_2' => 'Hero subtitle example from pattern library',
'show_illustration' => true,
'illustration_src' => @asset('images/illustrations/1.
]])
最佳答案
你不能。
但是,您可以仅将路径字符串发送到您的部分,并在您的部分中使用 @asset
指令。
关于php - 如何在另一个指令中调用 Laravel Blade 指令?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50839916/