The view helper method capture provides this functionality to wrap a section of the view template in a variable and can be used multiple times in the view.

Usage :

Advantage:

If its needed to render a section of template code, we usually go with partials. Capture is specifically useful when partial is only going to be used in just one view template. As there will be this variable available throughout the template, we can use it as many times as needed instead of partial.

Share this: