[增添]添加了datasource的setting数据库以及默认值
This commit is contained in:
54
vendor/ryangjchandler/blade-capture-directive/CHANGELOG.md
vendored
Normal file
54
vendor/ryangjchandler/blade-capture-directive/CHANGELOG.md
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
# Changelog
|
||||
|
||||
All notable changes to `blade-capture-directive` will be documented in this file.
|
||||
|
||||
## v0.3.0 - 2023-02-14
|
||||
|
||||
### What's Changed
|
||||
|
||||
- Add Laravel 10 support by @jyrkidn in https://github.com/ryangjchandler/blade-capture-directive/pull/12
|
||||
- Remove support for Laravel 8
|
||||
|
||||
### New Contributors
|
||||
|
||||
- @jyrkidn made their first contribution in https://github.com/ryangjchandler/blade-capture-directive/pull/12
|
||||
|
||||
**Full Changelog**: https://github.com/ryangjchandler/blade-capture-directive/compare/v0.2.2...v0.3.0
|
||||
|
||||
## v0.2.2 - 2022-09-02
|
||||
|
||||
**Full Changelog**: https://github.com/ryangjchandler/blade-capture-directive/compare/v0.2.1...v0.2.2
|
||||
|
||||
## v0.2.1 - 2022-08-23
|
||||
|
||||
### What's Changed
|
||||
|
||||
- chore(deps): bump dependabot/fetch-metadata from 1.3.0 to 1.3.1 by @dependabot in https://github.com/ryangjchandler/blade-capture-directive/pull/3
|
||||
- chore(deps): bump dependabot/fetch-metadata from 1.3.1 to 1.3.3 by @dependabot in https://github.com/ryangjchandler/blade-capture-directive/pull/4
|
||||
- fix: maintain `$this` binding of captured closure by @ryangjchandler in https://github.com/ryangjchandler/blade-capture-directive/pull/5
|
||||
|
||||
### New Contributors
|
||||
|
||||
- @dependabot made their first contribution in https://github.com/ryangjchandler/blade-capture-directive/pull/3
|
||||
|
||||
**Full Changelog**: https://github.com/ryangjchandler/blade-capture-directive/compare/v0.2.0...v0.2.1
|
||||
|
||||
## v0.2.0 - 2022-03-11
|
||||
|
||||
## What's Changed
|
||||
|
||||
- feature: capture enclosing environment by @ryangjchandler in https://github.com/ryangjchandler/blade-capture-directive/pull/2
|
||||
|
||||
## New Contributors
|
||||
|
||||
- @ryangjchandler made their first contribution in https://github.com/ryangjchandler/blade-capture-directive/pull/2
|
||||
|
||||
**Full Changelog**: https://github.com/ryangjchandler/blade-capture-directive/compare/v0.1.0...v0.1.1
|
||||
|
||||
## v0.1.0 - 2022-03-10
|
||||
|
||||
**Full Changelog**: https://github.com/ryangjchandler/blade-capture-directive/commits/v0.1.0
|
||||
|
||||
## 1.0.0 - 202X-XX-XX
|
||||
|
||||
- initial release
|
||||
21
vendor/ryangjchandler/blade-capture-directive/LICENSE.md
vendored
Normal file
21
vendor/ryangjchandler/blade-capture-directive/LICENSE.md
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) ryangjchandler <support@ryangjchandler.co.uk>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
116
vendor/ryangjchandler/blade-capture-directive/README.md
vendored
Normal file
116
vendor/ryangjchandler/blade-capture-directive/README.md
vendored
Normal file
@@ -0,0 +1,116 @@
|
||||
# Create inline partials in your Blade templates with ease.
|
||||
|
||||
[](https://packagist.org/packages/ryangjchandler/blade-capture-directive)
|
||||
[](https://github.com/ryangjchandler/blade-capture-directive/actions?query=workflow%3Arun-tests+branch%3Amain)
|
||||
[](https://github.com/ryangjchandler/blade-capture-directive/actions?query=workflow%3A"Check+%26+fix+styling"+branch%3Amain)
|
||||
[](https://packagist.org/packages/ryangjchandler/blade-capture-directive)
|
||||
|
||||
This package introduces a new `@capture` directive that allows you to capture small parts of your Blade templates and re-use them later on without needing to extract them into partials.
|
||||
|
||||
## Installation
|
||||
|
||||
You can install the package via Composer:
|
||||
|
||||
```bash
|
||||
composer require ryangjchandler/blade-capture-directive
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
This package adds a new pair of directives: `@capture` and `@endcapture`.
|
||||
|
||||
The `@capture` directive will capture all of your Blade until it reaches an `@endcapture` directive. It takes the code and stores it inside of a variable for usage later on.
|
||||
|
||||
```blade
|
||||
@capture($hello)
|
||||
Hello, world!
|
||||
@endcapture
|
||||
```
|
||||
|
||||
The directive requires at least 1 argument. This argument should be a PHP variable that you would like to assign your partial to. The variable itself will become a `Closure` that can be invoked inside of Blade echo tags (`{{ }}`) anywhere after it's definition.
|
||||
|
||||
```blade
|
||||
@capture($hello)
|
||||
Hello, world!
|
||||
@endcapture
|
||||
|
||||
{{ $hello() }}
|
||||
```
|
||||
|
||||
The above code will invoke your captured Blade code and output `Hello, world!` when compiled by Laravel and rendered in the browser.
|
||||
|
||||
The `@capture` directive also supports arguments. This means you can capture generalised chunks of Blade and change the output dynamically. This is achieved by specifying a comma-separated list of PHP variables like so:
|
||||
|
||||
```blade
|
||||
@capture($hello, $name)
|
||||
Hello, {{ $name }}!
|
||||
@endcapture
|
||||
```
|
||||
|
||||
The above code will require that a name is passed to `$hello()`, like below:
|
||||
|
||||
```blade
|
||||
@capture($hello, $name)
|
||||
Hello, {{ $name }}!
|
||||
@endcapture
|
||||
|
||||
{{ $hello('Ryan') }}
|
||||
```
|
||||
|
||||
The Blade will compile this and your view will output `Hello, Ryan!`. Cool, right?
|
||||
|
||||
The list of arguments can be treated like any set of arguments defined on a function. This means you can assign default values and specify multiple arguments:
|
||||
|
||||
```blade
|
||||
@capture($hello, $name, $greeting = 'Hello, ')
|
||||
{{ $greeting }} {{ $name }}!
|
||||
@endcapture
|
||||
|
||||
{{ $hello('Ryan') }}
|
||||
{{ $hello('Taylor', 'Yo, ') }}
|
||||
```
|
||||
|
||||
The above code will now output `Hello, Ryan!` as well as `Yo, Taylor!`. This is really cool, I know!
|
||||
|
||||
### Inheriting scope
|
||||
|
||||
All captured blocks will inherit the parent scope, just like a regular partial would in Blade. This means you can use any data passed to the view without having to pass it through to the block manually.
|
||||
|
||||
```blade
|
||||
@php($name = 'Ryan')
|
||||
|
||||
@capture($hello)
|
||||
Hello, {{ $name }}!
|
||||
@endcapture
|
||||
|
||||
{{ $hello() }}
|
||||
```
|
||||
|
||||
> If your captured block has a parameter with the same name as a predefined variable from the inherited scope, the block's parameter will always take precedence.
|
||||
|
||||
## Testing
|
||||
|
||||
```bash
|
||||
composer test
|
||||
```
|
||||
|
||||
## Changelog
|
||||
|
||||
Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.
|
||||
|
||||
## Contributing
|
||||
|
||||
Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.
|
||||
|
||||
## Security Vulnerabilities
|
||||
|
||||
Please review [our security policy](../../security/policy) on how to report security vulnerabilities.
|
||||
|
||||
## Credits
|
||||
|
||||
- [Ryan Chandler](https://github.com/ryangjchandler)
|
||||
- [All Contributors](../../contributors)
|
||||
|
||||
## License
|
||||
|
||||
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.
|
||||
70
vendor/ryangjchandler/blade-capture-directive/composer.json
vendored
Normal file
70
vendor/ryangjchandler/blade-capture-directive/composer.json
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
{
|
||||
"name": "ryangjchandler/blade-capture-directive",
|
||||
"description": "Create inline partials in your Blade templates with ease.",
|
||||
"keywords": [
|
||||
"ryangjchandler",
|
||||
"laravel",
|
||||
"blade-capture-directive"
|
||||
],
|
||||
"homepage": "https://github.com/ryangjchandler/blade-capture-directive",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Ryan Chandler",
|
||||
"email": "support@ryangjchandler.co.uk",
|
||||
"role": "Developer"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": "^8.1",
|
||||
"spatie/laravel-package-tools": "^1.9.2",
|
||||
"illuminate/contracts": "^10.0|^11.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"nunomaduro/collision": "^7.0|^8.0",
|
||||
"nunomaduro/larastan": "^2.0",
|
||||
"orchestra/testbench": "^8.0|^9.0",
|
||||
"pestphp/pest": "^2.0",
|
||||
"pestphp/pest-plugin-laravel": "^2.0",
|
||||
"phpstan/extension-installer": "^1.1",
|
||||
"phpstan/phpstan-deprecation-rules": "^1.0",
|
||||
"phpstan/phpstan-phpunit": "^1.0",
|
||||
"phpunit/phpunit": "^10.0",
|
||||
"spatie/laravel-ray": "^1.26"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"RyanChandler\\BladeCaptureDirective\\": "src",
|
||||
"RyanChandler\\BladeCaptureDirective\\Database\\Factories\\": "database/factories"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"RyanChandler\\BladeCaptureDirective\\Tests\\": "tests"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"analyse": "vendor/bin/phpstan analyse",
|
||||
"test": "vendor/bin/pest",
|
||||
"test-coverage": "vendor/bin/pest --coverage"
|
||||
},
|
||||
"config": {
|
||||
"sort-packages": true,
|
||||
"allow-plugins": {
|
||||
"pestphp/pest-plugin": true,
|
||||
"phpstan/extension-installer": true
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"laravel": {
|
||||
"providers": [
|
||||
"RyanChandler\\BladeCaptureDirective\\BladeCaptureDirectiveServiceProvider"
|
||||
],
|
||||
"aliases": {
|
||||
"BladeCaptureDirective": "RyanChandler\\BladeCaptureDirective\\Facades\\BladeCaptureDirective"
|
||||
}
|
||||
}
|
||||
},
|
||||
"minimum-stability": "dev",
|
||||
"prefer-stable": true
|
||||
}
|
||||
30
vendor/ryangjchandler/blade-capture-directive/src/BladeCaptureDirective.php
vendored
Normal file
30
vendor/ryangjchandler/blade-capture-directive/src/BladeCaptureDirective.php
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace RyanChandler\BladeCaptureDirective;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
final class BladeCaptureDirective
|
||||
{
|
||||
public static function open(string $expression): string
|
||||
{
|
||||
[$name, $args] = Str::contains($expression, ',') ?
|
||||
Str::of($expression)->trim()->explode(',', 2)->map(fn ($part) => trim($part))->toArray() :
|
||||
[$expression, ''];
|
||||
|
||||
return "
|
||||
<?php {$name} = (function (\$args) {
|
||||
return function ({$args}) use (\$args) {
|
||||
extract(\$args, EXTR_SKIP);
|
||||
ob_start(); ?>
|
||||
";
|
||||
}
|
||||
|
||||
public static function close()
|
||||
{
|
||||
return "
|
||||
<?php return new \Illuminate\Support\HtmlString(ob_get_clean()); };
|
||||
})(get_defined_vars()); ?>
|
||||
";
|
||||
}
|
||||
}
|
||||
22
vendor/ryangjchandler/blade-capture-directive/src/BladeCaptureDirectiveServiceProvider.php
vendored
Normal file
22
vendor/ryangjchandler/blade-capture-directive/src/BladeCaptureDirectiveServiceProvider.php
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace RyanChandler\BladeCaptureDirective;
|
||||
|
||||
use Illuminate\Support\Facades\Blade;
|
||||
use Spatie\LaravelPackageTools\Package;
|
||||
use Spatie\LaravelPackageTools\PackageServiceProvider;
|
||||
|
||||
class BladeCaptureDirectiveServiceProvider extends PackageServiceProvider
|
||||
{
|
||||
public function configurePackage(Package $package): void
|
||||
{
|
||||
$package->name('blade-capture-directive');
|
||||
}
|
||||
|
||||
public function packageBooted()
|
||||
{
|
||||
Blade::directive('capture', fn (string $expression) => BladeCaptureDirective::open($expression));
|
||||
|
||||
Blade::directive('endcapture', fn () => BladeCaptureDirective::close());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user