Support the ongoing development of →
Requests Views Blade
Last updated 1 year ago.

So there's this method available on the View facade that does something pretty neat.

This method is called renderSections()

Accessing this method goes a little bit like this:

// Make view, with variable for example
$view = View::make('')->with('name', 'JohnDoe');
return $view->renderSections()

Before we take a look at what this returns us, we must first look at our application layout.

If we have this for example:



Our renderSections() method will return us an array of the content we filled these sections with, for example:

array (size=2)
  'content' => string ' <div class='left well pull-left'>
      <h2>Sheikh Heera</h2>
      <p>Contact: 0123456789</p>
' (length=100)
  'sidebar' => string ' <div class='right well pull-right'>
' (length=148)

So, we can effectively build our html string for use with ajax like so :

if(Request::ajax()) {
    $view = View::make('card');
    $view = $view->renderSections();
    return join($view, '');


This seem awesome, I'll definitely take a look at renderSection. Thanks a lot.


Sign in to participate in this thread!


Your banner here too?

poudigne poudigne Joined 31 Jan 2016


We'd like to thank these amazing companies for supporting us

Your logo here?

The Laravel portal for problem solving, knowledge sharing and community building.

© 2023 - All rights reserved.