Skip to content

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

Merged
taylorotwell merged 2 commits into
7.xfrom
env-and-production-directives
May 11, 2020
Merged

[7.x] Implement env and production Blade directives#32742
taylorotwell merged 2 commits into
7.xfrom
env-and-production-directives

Conversation

@driesvints

@driesvints driesvints commented May 10, 2020

Copy link
Copy Markdown
Member

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

SjorsO commented May 10, 2020

Copy link
Copy Markdown
Contributor

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

@julienbourdeau

Copy link
Copy Markdown

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
Copy Markdown
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
Copy Markdown
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