Skip to content

[7.x] Implement env and production Blade directives #32742

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 11, 2020

Conversation

driesvints
Copy link
Member

@driesvints driesvints commented May 10, 2020

I often find myself doing this:

@if (app()->environment('production'))
    <!-- Some tracking code here -->
@endif

This pr allows for:

@production
    <!-- Some tracking code here -->
@endproduction

And also for more granular environment checking if needed:

@env('staging')
    <!-- Some tracking code here -->
@endenv

@driesvints driesvints force-pushed the env-and-production-directives branch from 22c3986 to 6459a5e Compare May 10, 2020 16:08
@SjorsO
Copy link
Contributor

SjorsO commented May 10, 2020

The docs have an example of a custom @env directive. The example should probably be changed if this gets merged.

@julienbourdeau
Copy link

I keep adding this custom directive to my project so that would be very useful! Plus, custom directive breaks the syntax coloring and open/close pairs 😄

Screenshot 2020-05-10 at 19 11 25

Thank you Dries! 👏

@linaspasv
Copy link
Contributor

I keep adding this custom directive to my project so that would be very useful! Plus, custom directive breaks the syntax coloring and open/close pairs 😄

Screenshot 2020-05-10 at 19 11 25

Thank you Dries! 👏

No, it does not break the syntax coloring if you are using it correctly. You should close it using @endenv.

@taylorotwell taylorotwell merged commit 86beb3e into 7.x May 11, 2020
@driesvints driesvints deleted the env-and-production-directives branch May 11, 2020 14:04
@driesvints
Copy link
Member Author

Thanks everyone. I've sent in a PR to update the existing docs example: laravel/docs#6043

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants