Consider implementing template fragments in Blade #44468
-
With the increasing popularity of various server render driven frontend frameworks (Turbo, Htmx, Unpoly to name a few) one feature that would make working with these types of frameworks much easier would be so called template fragments. A detailed description is available here. In short, it's a feature that allows us the ability to render only a fragment of a given template instead of the whole thing, without having to split out templates into many small files. Given a blade template: <div>
<div>Post title</div>
@fragment('status_controls')
<div>Archived</div>
<div>
<button>Unarchive</button>
<button>Delete</button>
</div>
@endfragment
<div>Some content</div>
</div> We could render the whole template on page load, and only the contents of the defined fragment on subsequent requests: view('post')->fragment('status_controls'); |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Submitted a PR for this. #44774 |
Beta Was this translation helpful? Give feedback.
-
It got merged 😃 |
Beta Was this translation helpful? Give feedback.
It got merged 😃