Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Advantages of using views/layout/main.volt vs everything in views/index.volt?

What are the advantages of using views/layout/main.volt vs having everything just be in views/index.volt?

The INVO app has navigation broken out into main.volt, but it seems the output would be identical if that code was just included in index.volt.

When would you want it broken out, and why?

Thanks!



54.8k
Accepted
answer

To reduce duplication. If you have multiple pages, you don't want to have to re-type the navigation on every page, so you break it out into its own file. I use partials for this, but there is probably a better way.



5.4k

That would already be accomplished by putting the navigation in views/index.volt (as opposed to views/whatever/index.volt, which is controller-specific).

But I guess if your top navigation was completely different in different controllers that wouldn't work, and having different layout views would make sense.

Thanks