@@ -66,7 +66,7 @@ public function __construct($templatePath = "", $attributes = [], $layout = "")
6666 */
6767 public function render (ResponseInterface $ response , $ template , array $ data = [])
6868 {
69- $ output = $ this ->fetch ($ template , $ data );
69+ $ output = $ this ->fetch ($ template , $ data, true );
7070
7171 $ response ->getBody ()->write ($ output );
7272
@@ -174,13 +174,14 @@ public function setTemplatePath($templatePath)
174174 *
175175 * @param $template
176176 * @param array $data
177+ * @param bool $useLayout
177178 *
178179 * @return mixed
179180 *
180181 * @throws \InvalidArgumentException
181182 * @throws \RuntimeException
182183 */
183- public function fetch ($ template , array $ data = []) {
184+ public function fetch ($ template , array $ data = [], $ useLayout = false ) {
184185 if (isset ($ data ['template ' ])) {
185186 throw new \InvalidArgumentException ("Duplicate template key found " );
186187 }
@@ -204,7 +205,7 @@ public function fetch($template, array $data = []) {
204205 $ this ->protectedIncludeScope ($ this ->templatePath . $ template , $ data );
205206 $ output = ob_get_clean ();
206207
207- if ($ this ->layout !== null ) {
208+ if ($ this ->layout !== null && $ useLayout ) {
208209 ob_start ();
209210 $ data ['content ' ] = $ output ;
210211 $ this ->protectedIncludeScope ($ this ->layout , $ data );
0 commit comments