<turbo-stream action="append" target="posts_list"><template>    <div class="postbit" id="124075" data-post-id="124075">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="IloSophiep" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/IloSophiep/120/20241_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  IloSophiep
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I wonder if i can help, but first: It sounds like you’re using Phoenix, but the code doesn’t look like you’re using Phoenix. When i create a new phoenix project my controllers need to include<br>
<code>use &lt;namespace&gt;Web, :controller</code><br>
so that the <code>Phoenix.Controller.render/3</code> function becomes available.</p>
<p>(That means my simple controller looks like this:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">defmodule T21517Web.HomeController do
  use T21517Web, :controller

  def index(conn, _params) do
    render(conn, "index.html")
  end
end
</code></pre>
<p>, where the namespace for the modules would of course differ in your case.)</p>
<p>The same way your view module should have a<br>
<code>use &lt;namespace&gt;Web, :view</code></p>
<p>Then i added the function clause you seem to want to include:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">def render("_test1.html", %{data: data}) do
  # I'm just returning some text here...
  "My data: #{inspect(data)}"
end
</code></pre>
<p>so my whole view module looks like this:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">defmodule T21517Web.HomeView do
  use T21517Web, :view

  def render("_test1.html", %{data: data}) do
    "My data: #{inspect(data)}"
  end
end
</code></pre>
<p>And now i can call this new <code>&lt;namespace&gt;Web.HomeView.render/2</code> clause from within my template:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">&lt;h1&gt;Home&lt;/h1&gt;

&lt;%= render("_test1.html", data: [1, 2, 3]) %&gt;
</code></pre>
<p>I did not include the view module as a parameter to <code>render/2</code>, because as <a class="mention" href="/u/overminddl1" rel="nofollow">@OvermindDL1</a> pointed out the template is “in the context of the view module”, so you can just call the render method directly.</p>
<p>If i missunderstood what you’re trying to do i can also imagine you wanting to call another view from within your home view. In my test i created a view module <code>T21517Web.BlaView</code>:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">defmodule T21517Web.BlaView do
  use T21517Web, :view

  def render("bla.html", %{data: data}) do
    "This is Bla's data: #{inspect(data)}"
  end
end
</code></pre>
<p>and in my template for the home view i added a call to the render function from that new module:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">&lt;h1&gt;Home&lt;/h1&gt;

&lt;%= render("_test1.html", data: [1, 2, 3]) %&gt;

&lt;%= render(T21517Web.BlaView, "bla.html", data: [4, 5, 7]) %&gt;
</code></pre>
<p>Everything seems to work fine for me:<br>
</p><div class="lightbox-wrapper"><a class="lightbox" href="https://forum.elixirforum.com/uploads/default/original/2X/6/6f0f4f9d7e4fff08481f3ef4efc6c4ec8a5a14a1.png" data-download-href="https://forum.elixirforum.com/uploads/default/6f0f4f9d7e4fff08481f3ef4efc6c4ec8a5a14a1" title="t21517" rel="nofollow"><img src="https://forum.elixirforum.com/uploads/default/optimized/2X/6/6f0f4f9d7e4fff08481f3ef4efc6c4ec8a5a14a1_2_690x233.png" alt="t21517" data-base62-sha1="fQtNMgEgBEnYtlLU9cKspmZ8zND" width="690" height="233" srcset="https://forum.elixirforum.com/uploads/default/optimized/2X/6/6f0f4f9d7e4fff08481f3ef4efc6c4ec8a5a14a1_2_690x233.png, https://forum.elixirforum.com/uploads/default/original/2X/6/6f0f4f9d7e4fff08481f3ef4efc6c4ec8a5a14a1.png 1.5x, https://forum.elixirforum.com/uploads/default/original/2X/6/6f0f4f9d7e4fff08481f3ef4efc6c4ec8a5a14a1.png 2x" data-dominant-color="F8F6F6"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">t21517</span><span class="informations">811×275 21 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div><p></p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="124075" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/how-to-alias-a-view-to-call-render-inside-an-html-page/21517/14">Post #13</a>
	                </div>
	            </div>
              <div id="likers-container-124075" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="124075"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-last-post cat-last-post" title="Last post!"></div>
  </section>
</div>
</template></turbo-stream><turbo-stream action="replace" target="load-more-container"><template><div id="load-more-container" class="load-more-container">
    <span class="all-loaded">— All posts loaded —</span>
</div></template></turbo-stream>