Propel rocketboost.rs

Nested section

A @section is a named piece of a page, and the layout places it where it yields that name. It must sit at the top level of the view. A section inside an @if, a loop, or another section is rejected, and rendering stops with an error.

What causes it

The view below puts a section inside a condition:

@if ($flag)
  @section('content')
    This content is inside an if block.
  @endsection
@endif

What you see

In a development build, the debug page names the section, the view, and the rule that was broken:

@section('content') in `errors.nested_section` must be at the top level of the template
The debug error page for a section inside an if block
The debug page for this error, as it appears in a development build.

This page is a debug-only demo, and its route is absent in a release build. A release build compiles only the views the app lists in build.rs, and this one is not listed, so the browser never sees this error in release. In release, a render error on a compiled view is a generic 500, and the details go to the log.

How to fix it

Keep the section at the top level, and move the condition inside it:

@section('content')
  @if ($flag)
    This content is inside an if block.
  @endif
@endsection

Sections are how a layout gets its content, and the layouts page explains the rules in full: layouts and sections.