Laravel 4 blade syntax within my javascript files
javascript, laravel, laravel-4, laravel-blade
Solution
you can try this save your javascript file in `app/views` folder and rename it to `xxx.blade.php` , yes `.blade.php` because Blade Engine will parse it only if its `.blade.php` and use `@include('your javascript filename')` to include the javascript file parsed by Blade, it will work.
Problem
My home page had some inline javascript that was mixed up with some blade syntax e.g. ``` <script type="text/javascript"> @if(Auth::user()) if(path.indexOf('/user/' + {{Auth::user()->id}} ) != -1) { $( "#tabs" ).tabs(); }; @endif </script> ``` It worked until I wanted to move the javascript to an external file.js. I got error whenever blade syntax was added. Is there a way I can fuse blade syntax in my javascript files.js? I tried renaming to file.blade.js with no luck...