Last active
August 29, 2021 11:55
-
-
Save antonioribeiro/f2a22e4b665643f7614ebaeb532c605e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Blade::extend(function ($view) { | |
return preg_replace( | |
'/{{(\'|")(.*)(\'|")}}/', | |
'<?php echo e(trans($1$2$1)); ?>', | |
$view | |
); | |
}); | |
// And you should be able to do tho this on your Blade templates | |
<h4> | |
{{'messages.welcome'}} | |
</h4> | |
// Instead of | |
<h4> | |
{{ trans('messages.welcome') }} | |
</h4> | |
No waste of resources, beucase this template: | |
<h1>{{ trans('message') }}</h1> | |
<h2>{{'message'}}</h2> | |
is compiled, once, to | |
<h1><?php echo e(trans('message')); ?></h1> | |
<h2><?php echo e(trans('message')); ?></h2> | |
And will stay cached until you change your view. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment