Reputation: 323
Hi I am new to Laravel 4 and have a question about loading CSS/JS files using the blade template engine. I am using an overall layout which contains a nav bar for every page. My question is if i want to include different CSS or JS files in the header of that page how would i accomplish this, i am extending the header. Here is an example
@extends('layouts.default')
@section('content')
{{HTML::script('js/example.js')}}
{{HTML::style('css/example.css')}}
@stop
Obviously my content section starts in the body of the default layout, and when i view page source on this the and tags appear in the body. Does this matter?
Any help appreciated. Thanks!
Upvotes: 3
Views: 5874
Reputation: 323
Roughly 3 seconds after I posted this I figured it out, I guess thats the way learning goes.
Make a header section in the view and yield that in the header like so...
View:
@extends('layouts.default')
@section('header')
{{HTML::script('js/example.js')}}
{{HTML::style('css/example.css')}}
@stop
@section('content')
// page stuff
@stop
layout:
<!DOCTYPE html>
<html>
<head>
@yield('header')
</head>
<body>
@yield('content')
</body>
</html>
Upvotes: 9