laravel / folio

Page based routing for Laravel.
MIT License
568 stars 46 forks source link

Adds `renderWhen` and `renderUnless` methods #101

Closed mahmoudmohamedramadan closed 1 year ago

mahmoudmohamedramadan commented 1 year ago

This PR adds two methods that work under the given condition. Let's demonstrate with the next example

// user/[id].blade.php

<?php
    use function \Laravel\Folio\renderWhen;

    // This method will work if the given condition is true otherwise, the closure will not be executed
    renderWhen(true, function($view) {
        $post = ['title' => 'Welcome renderWhen Method!'];

        return $view->with('post', $post);
    });
?>

<?php  echo $post['title']; ?>
taylorotwell commented 1 year ago

Thanks for your pull request to Laravel!

Unfortunately, I'm going to delay merging this code for now. To preserve our ability to adequately maintain the framework, we need to be very careful regarding the amount of code we include.

If possible, please consider releasing your code as a package so that the community can still take advantage of your contributions!

If you feel absolutely certain that this code corrects a bug in the framework, please "@" mention me in a follow-up comment with further explanation so that GitHub will send me a notification of your response.