diff --git a/src/Illuminate/View/View.php b/src/Illuminate/View/View.php index a5e095857501..fd0899ce2f13 100755 --- a/src/Illuminate/View/View.php +++ b/src/Illuminate/View/View.php @@ -90,6 +90,22 @@ public function fragment($fragment) }); } + /** + * Get the evaluated contents of a given fragment if the given condition is true. + * + * @param bool $boolean + * @param string $fragment + * @return string + */ + public function fragmentIf($boolean, $fragment) + { + if (value($boolean)) { + return $this->fragment($fragment); + } + + return $this->render(); + } + /** * Get the string contents of the view. *