Two Views at Once

I am building a site that uses a vertically split window.

I want to show view A in the left side of the split and view B in the right side of the split.

Is there a way to direct, from within a controller, which side (view A or B) the view gets rendered in or do I have to statically define, from within the template which view gets rendered in each side?

You could do something like this.

defmodule MyApp.FooController do
  def index(conn, params) do
    render("split.html", left: MyApp.AView, right: MyApp.BView)

In your view you would have something like

<div class="col-lg-6" id="left_split">
    <%= render(@left, "left.html", assigns) %>

<div class="col-lg-6" id="right_split">
    <%= render(@right, "right.html", assigns) %>

Obviously you would need to have a corresponding left and right templates.


DUH! Why didn’t I think of that!!! It’s so obvious!!!

Many thanks!