Blade Language syntax highlighting for Prism.
npm i prism-blade
<!-- Get Prism from the CDN -->
<script src="https://cdn.jsdelivr.net/npm/prismjs@1.29.0/prism.min.js"></script>
<!-- Make sure to include the following language definitions -->
<script src="https://cdn.jsdelivr.net/npm/prismjs@1.29.0/components/prism-php.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/prismjs@1.29.0/components/prism-javascript.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/prismjs@1.29.0/components/prism-css.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/prismjs@1.29.0/components/prism-markup-templating.min.js"></script>
<!-- Then include the script from the CDN -->
<script src="https://cdn.jsdelivr.net/npm/prism-blade@latest/dist/prism-blade.min.js"></script>
import Prism from 'prismjs';
import 'prism-blade';
const code = `@include('header')`;
const html = Prism.highlight(code, Prism.languages.blade, 'blade');
Hello, {{ $name }}.
The current UNIX timestamp is {{ time() }}.
Your favorite color is {{ Auth::user()->getFavorite('color') }}.
<link href="{{ asset('css/dashboard.css') }}" rel="stylesheet">
<body class="{{ $isDark ? 'dark' : 'light' }}">Hi!</body>
{!! Auth::user()->name !!}
{{-- This is a comment --}}
@extends('layouts.app')
@section('title', 'Dashboard')
@json(['user' => Auth::user(), 'notifications' => $notifications])
@can('edit-posts')
<p>You can edit posts.</p>
@elsecan('view-posts')
<p>You can view posts.</p>
@else
<p>Access denied.</p>
@endcan
<x-alert
type="error"
:name="auth()->user()->name"
:message="$message->getMessage()" />
<x-inputs.button/>
<style>
.card { color: red; }
</style>
@push('scripts')
<script>
document.addEventListener('DOMContentLoaded', function() {
console.log('Loaded');
});
</script>
@endpush
@php
$userRole = Auth::user()->role;
@endphp
<html>
@verbatim
This will not be parsed as Blade: {{ foo }}
<!-- A comment -->
<script>console.log('Bar');</script>
@endverbatim
</html>