When you add the secondline:
@include('javascript.views.view1')
What did you mean?
Is it a partial view that is within the javascript > views folder structure?
I generally have a section for my page-specific javascript.
Example template.blade.php
<body>
@yield('content')
@include('_partial.scripts')
@yield('page-script')
@include('_partial.footer')
</body>
Example : view-name.blade.php
@section('title', 'My Awesome Page')
@section('content')
My DataTables...
@stop
@section('page-script')
<script type="text/javascript">
// my custom script
</script>
@stop
You could also open & close script
tags in template but this setup helps IDE to understand that I am writing JS !
###Improvements ?
I am okay with this setup because it lets me manage the script right in the view where it is used. But, I am unable to do stuffs like minify ... Any ideas ?
I have a default layout (simplified) like this :
...
<div id="main" class="row">
@include('partials.flash')
@yield('content')
</div>
...
@yield('scripts')
My folder structure is as following :
@mcraz I used to it this way, but I wanted to separate the javascript related to my views in specific files, not in the view file itself. That's why I'm asking.
Why don't you use an assets folder with a js, css, and img folder within the public folder?
codeATbusiness said:
Why don't you use an assets folder with a js, css, and img folder within the public folder?
I have one to store my css, my images and the functionnal javascript.
The problem is that I need to use Blade in some of my Javascript (basically, to generate AJAX URLs for example).
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community