将部分分配给变量

我有一节:

@section('info') 
code 
@endsection

I want to assign the section to a variable $output. Is this possible? For example echo $output would echo the output from the section. I know I can use @yield('info') but I can't use @yield in if statements etc.