PHP code example of cbl / blade-script

1. Go to this page and download the library: Download cbl/blade-script library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

cbl / blade-script example snippets


<button class="btn" onlick="myFunction()">{{ $slot }}</button>

<x-script>
function myFunction() {
    // Do something.
}
</x-script>

<body>
    ...

    <x-scripts />
</body>

<button class="btn" onlick="myFunction()">{{ $slot }}</button>

<x-script>
myFunction() {
    // Do something.
}
</x-script>


namespace BladeBabel;

use Babel\Transpiler as Babel;
use BladeScript\Contracts\Transpiler;

class BabelTranspiler implements Transpiler
{
    public function transpile($script)
    {
        return Babel::transform($script);
    }
}


namespace BladeBabel;

use Illuminate\Support\ServiceProvider;

class BabelServiceProvider extends ServiceProvider
{
    public function register()
    {
        $this->app->afterResolving('script.compiler', function ($compiler) {
            $compiler->addTranspiler(new BabelTranspiler);
        });
    }
}
shell
php artisan vendor:publish --provider="BladeScript\ServiceProvider"
shell
php artisan script:cache
shell
php artisan script:clear