Hello,
I'm creating an email management system - emails are blade templates which are assembled in a controller, and then are passed to view, to display the content in the backend. As such I've:
Email template:
@extends('emails/layouts/default')
@section('content')
Test
@endsection
Model that assembles the content, with function render:
public function render($with = [])
{
return View::make("emails.".$this->template_file)->with($with);
}
Controller that passes given content of the email, with show method:
public function show(Model $model)
{
return view('admin.emails.show')->with(['content' => $model->render()]);
}
Backend template to present the email:
@extends('admin.layouts.master')
@section('content')
<iframe class='rendered-content' srcdoc="{{$content}}"></iframe>
@stop
The result is... unexpected - even though the views are separated, because they both use the content section, the backend template will display Test instead of <iframe class='rendered-content' srcdoc="Test"></iframe>.
I've to do, in Model:
public function render($with = [])
{
return View::make("emails.".$this->template_file)->with($with)->render();
}
to separate the layouts (scopes) of templates.
My questions is - is this a valid behaviour? Shouldn't layouts in this instance create their own scopes (as we're dealing with, de-facto, nested layouts) or does Blade layouts not support nesting and everything is stored in global scope (as is shown above) and there's no way to change this.