Created
March 18, 2021 22:03
-
-
Save felixdorn/7b57da4b14aefbed53d430510e7bd40e to your computer and use it in GitHub Desktop.
This file contains hidden or 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::directive('alpine', function (string $variables) { | |
return <<<PHP | |
<?php | |
\$data = array_combine( | |
array_map( | |
fn (\$variable) => str_replace('$', '', \$variable), | |
explode(',', '$variables') | |
), | |
[$variables] | |
); | |
echo trim( | |
str_replace(["'", '"'], ["\'", "'"], json_encode(\$data)), | |
'{}' | |
); | |
?> | |
PHP; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment