Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/prinsfrank/indentingpersistentbladecompiler
Extension on the Laravel Blade compiler that persists indenting when using replaced content in blade templates.
https://github.com/prinsfrank/indentingpersistentbladecompiler
blade blade-compiler blade-template-engine compiler laravel laravel-framework laravel-package template-compiler
Last synced: 2 months ago
JSON representation
Extension on the Laravel Blade compiler that persists indenting when using replaced content in blade templates.
- Host: GitHub
- URL: https://github.com/prinsfrank/indentingpersistentbladecompiler
- Owner: PrinsFrank
- License: mit
- Created: 2019-07-01T18:19:22.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2022-02-23T21:06:17.000Z (almost 3 years ago)
- Last Synced: 2024-10-14T08:41:38.514Z (3 months ago)
- Topics: blade, blade-compiler, blade-template-engine, compiler, laravel, laravel-framework, laravel-package, template-compiler
- Language: PHP
- Size: 102 KB
- Stars: 17
- Watchers: 3
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Indenting persistent blade compiler
[![Build Status](https://travis-ci.org/PrinsFrank/IndentingPersistentBladeCompiler.svg?branch=master)](https://travis-ci.org/PrinsFrank/IndentingPersistentBladeCompiler)
Have you ever looked at the HTML Laravel generates and wondered about the mess? That's what I want to solve with this package. [As this is not going to be fixed in Laravel Framework itself](https://github.com/laravel/framework/pull/28768) I decided to make it into a package, and here it is!
## The problem
An example with all replaced content types:
```
// app.blade.php
@push('scripts')@endpush
@stack('scripts')
@section('sidebar')
@show
@yield('content')
```
```
// main.blade.php
@extends('example.app')@section('sidebar')
@parent@endsection
@section('content')
@include('example.include')
@includeif('example.include')
@includewhen(true, 'example.include')
@includefirst(['example.include', 'example.include'])
@each('example.include', [1,2], 'index')
@component('example.component')
@slot('title')
@endslot
@endcomponent@endsection
```
```
// component.blade.php
{{ $title }}
{{ $slot }}```
```
// include.blade.php```
Results in the following HTML. What a mess, right?
```
```
This package fixes that and generates the following HTML:
```
```
## Setting things up
Run ```composer require prinsfrank/indenting-persistent-blade-compiler```
Run ```php artisan view:clear``` to clear the already compiled views. Don't forget to do this when deploying to production as well, existing templates will break!