So you want to render multiple elm programs inside a laravel application?
This package makes it seamless.
Required: The partner Javascript library with the same name, npm i laravel-elm --save-dev
const mix = require('laravel-mix');
const elm = require('laravel-elm');
mix.js('resources/js/app.js', 'public/js')
.sass('resources/sass/app.scss', 'public/css')
.then(elm);
composer require tightenco/laravel-elm
php artisan elm:create Example
npm run watch
You may then use the Elm
facade to view your Elm apps.
use Tightenco\Elm\Elm;
...
public function index()
{
return view('home', [
'Example' => Elm::make('Example'),
]);
}
And then render it in your view:
{!! $Example !!}
Hello, World!
You can generate a program with flags via
php artisan elm:create Example --with-flags
use Tightenco\Elm\Elm;
...
public function index()
{
return view('home', [
'Example' => Elm::make('Example', [
'value' => 'Hello, World!'
// You can pass anything you might need:
// 'csrfToken' => csrf_token(),
// 'user' => auth()->user(),
]),
]);
}
View the license for this repo.