3 Matching Annotations
- Jan 2024
-
mattbrictson.com mattbrictson.com
-
Some frameworks call this “template inheritance”. In this example, we might say that the application layout “inherits from” or “extends” the base layout. In Rails, this is known as nested layouts, and it is a bit awkward to use. The standard Rails practice for nested layouts is complicated and involves these considerations
-
But what if you want to reuse one layout within another?
-
Here’s my common practice: Every page in the app needs the standard HTML boilerplate with my common stylesheets and JavaScripts. I need a layout that provides these, but makes no assumptions on the actual body of the page. This is my “base” layout. Most – but not all – pages in the app need a common header and footer. This is my “application” (default) layout. I’d like the application layout to reuse the base layout to keep my code DRY.
-