Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
98
rated 0 times [  100] [ 2]  / answers: 1 / hits: 28522  / 11 Years ago, tue, august 6, 2013, 12:00:00

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...


More From » laravel

 Answers
4

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.


[#76510] Sunday, August 4, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
keyonnal

Total Points: 746
Total Questions: 103
Total Answers: 116

Location: Moldova
Member since Sat, Aug 6, 2022
2 Years ago
;