Log1x / sage-directives

A set of Blade directives for use with Roots Sage.
https://log1x.github.io/sage-directives-docs/
MIT License
284 stars 35 forks source link

How to use directives within components/partials parameters? #146

Closed kvnol closed 7 months ago

kvnol commented 7 months ago

Is it possible to use parameters in components or partials within blades?

@hassub('button')
  @group('button')
    @sub('title') {{-- it works --}}
    @sub('href') {{-- it works --}}
    @sub('icon') {{-- it works --}}

    <div class="s-header-banner__button">
      <x-button label="{{ @sub('title') }}" href="{{ @sub('href') }}" icon="{{ @svg('pixelarticons-heart') }}" />
      {{-- does not works --}}

      @include('components.button', [
        'label' => @sub('title')
      ])
      {{-- does not works --}}
    </div>
  @endgroup
@endsub

I get different errors.

Log1x commented 7 months ago

Hi!

Unfortunately Laravel doesn't support using directives inside of directives. You'll have to pass it the old fashion way using get_sub_field().

kvnol commented 7 months ago

@Log1x ok, no problems. Thanks a lot!