Roots Discourse

Accessing view in ajax loop

Making AJAX response handler that send rendered view back.

I know I can show view with view('partials.content')->render(), but how I can replicate following Blade syntax

@includeFirst(['partials.content-' . get_post_type(), 'partials.content'])

if I trow an array to view it just throw me an error… and I have several post types and this need to be dynamic

Make a partial containing that blade syntax and then call that partial.

I did think about going that route but wanted to double check is there is something like includeFirst on backend…
If all fail I will use this solution…

To the best of my knowledge there is no out-of-the-box solution to replicate the behavior of includeFirst outside of Blade. The logic it’s executing is very simple (“Does this file exist? If yes, load it; if not, load this other one”) so you could theoretically roll your own, but wrapping it in a secondary blade seems like a much simpler solution that leverages existing systems to me.

1 Like

I just want to thank you for help will go with your suggestion then…

1 Like