Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel - laracasts/PHP-Vars-To-Js-Transformer

Tags:

laravel-5

I'm trying to get this package to work: https://github.com/laracasts/PHP-Vars-To-Js-Transformer

I did everything according to the description, but I get no output of the variables.

Laravel Version: laravel/framework (v5.2.24)

My config/app

Laracasts\Utilities\JavaScript\JavaScriptServiceProvider::class,
'JavaScript' => Laracasts\Utilities\JavaScript\JavaScriptFacade::class,

My config/javascript

'bind_js_vars_to_this_view' => 'footer',
'js_namespace' => 'qwerTEST'

in my controller

use JavaScript;
JavaScript::put(['fett' => 'testtesttest']);

in my main view

@include('layouts.footer');

my footer.blade.php

`<div>some text</div>`

and in my view

@extends('layouts.intern')

@section('content')
    <script>
        console.log('test');
        console.log(qwerTEST.fett);
    </script>
@endsection

the javascript of chrome gives out

test
Uncaught ReferenceError: qwerTEST is not defined

And there is nothing with qwerTEST javascript namespace in the sourcecode. But I get no error at all.

Am I missing something?

like image 525
ndberg Avatar asked Dec 08 '25 08:12

ndberg


1 Answers

I found it: in my config/javascript I have to write the full path to the view:

'bind_js_vars_to_this_view' => 'folder.footer'

Could be better described in the Package..

like image 124
ndberg Avatar answered Dec 10 '25 02:12

ndberg



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!