laravel-mix-edge v0.2.0
laravel-mix-edge
Laravel Mix Plugin for compiling Edge templates.
Introduction
This package provides a plugin for Laravel Mix to compile Edge templates. laravel-mix-edge requires Laravel Mix to work. Please follow the instructions on how to use it on the package repository.
Usage
Install this package into your project:
npm install laravel-mix-edge --save-devHead over to your webpack.mix.js and register it on the Laravel Mix API:
let mix = require('laravel-mix');
require('laravel-mix-edge');
mix.js('src/app.js', 'dist')
.sass('src/app.scss', 'dist')
.edge('src/views', 'dist')
.setPublicPath('dist');Options
You can also pass in a third optional parameter: options object. It accepts two options:
seeds
This is a path to a folder with seed files. Files can be of type json or yaml. They will be parsed and provided in your Edge template locals under the seed file name and then contents.
mix.edge('src/views', 'dist', {
seeds:'src/seeds'
});And if you have a file demo.yml in there all the content will be available in your template under
<a href="{{ demo.anchor.link }}">
{{ demo.anchor.name }}
</a>locals
It's possible to pass in an object which will be added to locals in your Edge templates:
mix.edge('src/view', 'dist', {}, {
locals: {
config: { baseUrl: 'http://my-template.dev/' }
}
});and in your edge file:
<link rel="stylesheet" href="{{ config.baseUrl }}css/main.css">
<script src="{{ config.baseUrl }}js/main.js"></script>outputExtension && sourceExtension
It is possible to change to output file and source file extension.
mix.edge('src/views', 'dist', {
sourceExtension: '.edge.html',
outputExtension: '.blade.php',
});edge
It is possible to set options to Edge library.
mix.edge('src/views', 'dist', {}, {
edge: {}
});global
Globals are key/value pairs available to all of your templates. Edge ships with a bunch of commonly used globals. Also, you can add your own globals to the edge instance. More info
mix.edge('src/views', 'dist', {}, {
global: {
'json': data => JSON.stringify(data),
}
});presenters
View Presenter is a way to encapsulate complex logic inside a dedicated class, instead of writing it inside your template files. Also, it is very important to understand the philosophy behind a Presenter before you can really empower it. More info
mix.edge('src/views', 'dist', {
presenters: 'src/presenters'
});License
Laravel Mix Edge is open-sourced software licensed under the MIT license.