Reputation: 1005
I'm new to Laravel 5 i while searching over internet i for some basic concepts i found that in Laravel we can link assets dynamically i didn't understand how can we link them dynamically.
How can we know that an asset is used in certain point and include it in the view.
As per my knowledge i'm writing all the assets in one blade template and extending in views.
example.blade.php
{{Html::Style('somefile')}}
{{Html::script('somefile')}}
custom view.blade.php
@extends('example)
But how come this do Dynamically?
Upvotes: 0
Views: 1774
Reputation: 1804
In main template layout.blade.php, you have common includes:
<html>
<head>
... common JS/CSS
@yield('css')
@yield('js')
</head>
in custom page template custom.blade.php, where you extend main template you can add dynamically additional CSS or JS by adding sections:
@extends('layouts.layout')
{{-- dynamic JS/CSS definitions --}}
@section('css')
{{Html::Style('some new CSS file only for this template')}}
@endsection
@section('js')
{{Html::script('some new JS file only for this template')}}
@endsection
@section('content')
Your custom page content
@endsection
Read more about blade sections.
Upvotes: 1
Reputation: 2736
Include css
<link href="{{ asset('/css/admin.css') }}" rel="stylesheet">
Include js
<script src="{{ asset('/js/jquery.min.js') }}"></script>
Upvotes: 0