Skip to main content
Back to packages
624 GitHub stars

spatie/laravel-blade-javascript

View on GitHub

Description

A Blade directive to export variables to JavaScript

This package contains a Blade directive to export values to JavaScript.

Here's an example of how it can be used:

@javascript('key', 'value')

The rendered view will output:

<script>window['key'] = 'value';</script>

So in your browser you now have access to a key variable:

console.log(key); //outputs "value"

Recent Courses on Laravel Daily