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

You could use smth like this

@include('view.name')
Last updated 1 year ago.
0

Oh Thanks for reply. But I need a custom include: different for each controller method

Last updated 1 year ago.
0

Set views path as variable in a controler and use in a blade file like so

@inlclude($customViewPath)

P.S. If you are using those views for assrt loading than maybe you shold check something like this package

Last updated 1 year ago.
0

Just an example:

Your controller:

class HomeController extends BaseController {

	public $jsfiles = ['jquery.js', 'bootstrap.js'];

	public function index() {
		return View::make('home.index')->with('jsfiles', $this->jsfiles);
	}
}

layouts/master.blade.php

@section('js')
    {{-- default js to show in all pages --}}
    {{ HTML::script('default.js') }}
@show

@yield('content')

home/index.blade.php

@extends('layouts.master')

@section('js')
    parent // add @ before this call, forum doesnt render it

    @if($jsfiles)
        @foreach($jsfiles as $js)
            {{ HTML::script($js) }}
        @endforeach
    @endif
@stop

@section('content')
    {{ 'my content' }}
@stop
Last updated 1 year ago.
0

Oh. Thanks all. I think diego1araujo reached my target. The package, instead, is too much for me. Thanks again

Last updated 1 year ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

satienet satienet Joined 7 Mar 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.