Question

I am designing a back end for a site in Laravel 4. It will have a number of data entry forms, some of which will be broken up into tabbed pages.

For an individual view it looks like this:

<ul>
<li id='menu0' class='menu active'>Main</li>
<li id='menu1' class='menu'>Secondary</li>
<li id='menu2' class='menu'>Advanced</li>
</ul>

<div id='tab0' class='tab active'>
@include('_mainfields')
</div>

<div id='tab1' class='tab'>
@include('_secondfields')
</div>

<div id='tab2' class='tab'>
@include('_advancedfields')
</div>

Ideally, I want to convert this to a macro:

Form::tabify(['Main','Secondary','Advanced'],'_mainfields','_secondfields','_advancedfields'])

A typical @include file would contain blade code like this:

<div class='formfield'>
{{ Form::label('dress_description','Description') }}
{{ Form::input('text','dress_description') }}
</div>

Writing a macro to generate the UL portion is trivial. However, I hit a wall when it comes to the includes. I can't see how I can extract that out to the macro. The macro itself can't contain an @include, as its written in PHP. A php include wouldn't work, as the blade code in the include wouldn't get processed.

So is there another way?

Was it helpful?

Solution

You can render them directly:

View::make('your-included-template');
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top