在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):spatie/laravel-blade-javascript开源软件地址(OpenSource Url):https://github.com/spatie/laravel-blade-javascript开源编程语言(OpenSource Language):PHP 99.2%开源软件介绍(OpenSource Introduction):A Blade directive to export variables to JavaScriptThis package contains a Blade directive to export values to JavaScript. Here's an example of how it can be used: @javascript('key', 'value') The rendered view will output: <script>window['key'] = 'value';</script> So in your browser you now have access to a key variable: console.log(key); //outputs "value" Spatie is a webdesign agency based in Antwerp, Belgium. You'll find an overview of all our open source projects on our website. Support usWe invest a lot of resources into creating best in class open source packages. You can support us by buying one of our paid products. We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on our contact page. We publish all received postcards on our virtual postcard wall. InstallationYou can install the package via composer: composer require spatie/laravel-blade-javascript The package will automatically register itself. Optionally the config file can be published with php artisan vendor:publish --provider="Spatie\BladeJavaScript\BladeJavaScriptServiceProvider" --tag="config" This is the contents of the published config file: return [
/**
* All passed values will be present in this JavaScript namespace. Set this to an empty string
* to use the window object.
*/
'namespace' => '',
]; If you want to customize the generated php artisan vendor:publish --provider="Spatie\BladeJavaScript\BladeJavaScriptServiceProvider" --tag="views" After this you can edit the published view UsageWith the package installed you can make use of a @javascript('key', 'value') The rendered view will output: <script>key = 'value';</script> You can also use a single argument: @javascript(['key' => 'value']) This will also output: <script>key = 'value';</script> When setting the namespace to eg <script>window['js'] = window['js'] || {};js['key'] = 'value';</script> ChangelogPlease see CHANGELOG for more information what has changed recently. Testing$ composer test ContributingPlease see CONTRIBUTING for details. SecurityIf you've found a bug regarding security please mail [email protected] instead of using the issue tracker. CreditsThis repository contains some code from the laracasts/PHP-Vars-To-Js-Transformer package written by Jeffrey Way. LicenseThe MIT License (MIT). Please see License File for more information. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论