@cacheIf new directive idea #14
garzettone
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi, using this fantasitc plugin I realized that often I need to use the @cache directive only if a condiction is true. I know I can put the @cache directive inside a @if directive but in this way I need to write the @else statement and duplicate code. So I'd like to have a sort of @cacheIf(condition,key,ttl) statement where the cache is applied only if "condition" is true.
Here it is an example of blade code without @cacheIf
@if($user->id=123)
@cache($user->id)
.... a lot of html and more code
@endache
@else
.... a lot of html and more code
@endif
as you can see I have to duplicate " .... a lot of html and more code" if I want apply cache only in some circustances.
Here the blade code if @cacheIf should exists.
@cacheIf($user->id=123, $user->id)
.... a lot of html and more code
@endache
As you can see the ".... a lot of html and more code" doesn't need to be repeated.
It should be great!!!!
Beta Was this translation helpful? Give feedback.
All reactions