Error with shortcode rendering blade template

Hello, I have an acf flexible content field that I am using for my own custom page builder components.

page.blade.php looks like this:


  @while(have_posts()) @php(the_post())
  @include('', ['pb_data' => $pageBuilder])

$pageBuilder is an array of all the data that has been setup and formatted in App.php. In the file I just have a switch case getting the flexible content layout names and including the correct partial for that module like so:

@foreach($pb_data  as $layout)
      @include('partials.module-text', $layout['module_data'])

      @include('partials.module-dual-feature-cards', $layout['module_data'])

This all works but when I setup a shortcode that tries to render a view, it duplicates all of the content of the page-builder.blade.php file.

here is my shortcode setup:

add_shortcode('list-group-link', function( $atts, $content = null ) {

    // Extract the shortcode attributes
    $atts = shortcode_atts( array(
      'link' => '#',
      'heading' => 'Heading',
      'subheading' => 'Subheading',
      'cta_text' => 'Learn More',
    ), $atts );

    return view('components.list-group-link', [
      'link' => $atts['link'],
      'heading' => $atts['heading'],
      'subheading' => $atts['subheading'],
      'cta_text' => $atts['cta_text'],
    ] );


If anyone has insight as to what is causing this to duplicate the rendering of the entire page builder, it would be greatly appreciated. If I comment out the return view(components.list-group-link... part of the shortcode and just return a test string everything works fine again.

Thank you

:thinking: view(...) should be followed by a render().

This should be helpful:

(From the email template render example in that doc page):

$message = view('emails/welcome', compact('user', 'blogname', 'password_reset_link'))->render();