Skip to content

Commit

Permalink
add missing renderWhen method (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
pontoffeltier authored and TerrePorter committed Apr 6, 2018
1 parent 03ed8a6 commit afef1ef
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,24 @@ protected function makeStringView(array $view, $data=[])
});
}

/**
* Get the rendered content of the view based on a given condition.
*
* @param bool $condition
* @param string $view
* @param array $data
* @param array $mergeData
* @return string
*/
public function renderWhen($condition, $view, $data = [], $mergeData = [])
{
if (! $condition) {
return '';
}

return $this->make($view, $this->parseData($data), $mergeData)->render();
}

/**
* Get the rendered contents of a partial from a loop.
*
Expand Down

0 comments on commit afef1ef

Please sign in to comment.