Support the ongoing development of Laravel.io →
posted 9 years ago
Views Blade
Last updated 1 year ago.
0

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?

Last updated 1 year ago.
0

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 ?

Last updated 1 year ago.
0

@codeATbusiness

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 :

  • app/
    • views/
      • view1.blade.php
      • javascript/
        • views/
          • view1.blade.php

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

Last updated 1 year ago.
0

Why don't you use an assets folder with a js, css, and img folder within the public folder?

Last updated 1 year ago.
0

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

Last updated 1 year ago.
0

Any new ideas on these?

0

Did you consider using assets pipeline? https://github.com/CodeSleeve/asset-pipeline

0

Sign in to participate in this thread!

Eventy

Your banner here too?

bfiaut bfiaut Joined 7 May 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.