Are there some drawbacks by allowing template subfolders in Phoenix projects?

Here’s what I do when I decide to break up a template into many smaller ones. Let’s say the main template is index.eex. I just create the sub-templates in the same directory but use a descriptive name that starts with an underscore like _header.eex, _slider.eex etc. Since the sub-template names all start with an underscore, they naturally sort above the main template. You can get creative with the sorting by using numbers in the names etc.
If I happen to have more than one main template in the same directory (which is rare), I just use it’s name as a prefix in the sub-template name, like _index-header.eex, _index-slider.eex.

I find this works pretty well for me most of the time.

1 Like