Hey all - so for my purposes I’ve resolved this problem. Rather than trying to work around the use MyApp.Web, :view call, I went straight to the source and added the pattern option directly to the primary MyApp.Web.view definition:
# /lib/my_app/web/web.ex
def view do
quote do
use Phoenix.View, root: "lib/my_app/web/templates",
pattern: "**/*",
namespace: MyApp.Web
..
end
end
This allowed me to create multiple sub-dirs within each view root directory (for my purposes this was web/templates/page), and then to call renders inside of master index.html template using relative paths from that root directory:
# /lib/my_app/web/templates/page/index.html.haml
# please note that all of my view templates use HAML
.container
-# Top Section
= render MyApp.Web.PageView, 'sections/_top_section.html'
-# More Stuff Section
= render MyApp.Web.PageView, 'sections/_more_stuff.html'
-# Final Stuff Section
= render MyApp.Web.PageView, 'sections/final_stuff.html'
Additionally, because I ended up with about 12 partials overall, and because my app name was pretty long, I decided to alias the PageView module within itself for easier partial calls:
# /lib/my_app/web/views/page_view.ex
defmodule MyApp.Web.PageView do
use MyApp.Web, :view
alias MyApp.Web.PageView
end
This made my primary index template a big more svelte:
# /lib/my_app/web/templates/page/index.html.haml
.container
-# Top Section
= render PageView, 'sections/_top_section.html'
-# More Stuff Section
= render PageView, 'sections/_more_stuff.html'
-# Final Stuff Section
= render PageView, 'sections/final_stuff.html'
Anyway, happy to answer any questions, or field any fire for doing any of these things incorrectly according to convention. Also please note that I’m using Phoenix 1.3-rc2, so this may be different for Phoenix 1.2.4 apps.