Skip to content

sisyphushappy/laravel-elm

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Laravel Elm logo

Render your Elm programs from Laravel

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

https://github.com/loganhenson/laravel-elm

Add the elm runner to your webpack.mix.js e.g.:

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);

Installation

composer require tightenco/laravel-elm

Create your first Elm application

php artisan elm:create Example

Watch your elm files just like you would everything else

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 even pass flags to your Elm application

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(),
        ]),
    ]);
}

License

View the license for this repo.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 85.8%
  • Elm 14.2%