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


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>From the docs (<a href="https://hexdocs.pm/phoenix/views.html" rel="noopener nofollow ugc">https://hexdocs.pm/phoenix/views.html</a>)</p>
<p>“Phoenix views have two main jobs. First and foremost, they render templates (this includes layouts). The core function involved in rendering, <code>render/3</code> , is defined in Phoenix itself in the <a href="https://hexdocs.pm/phoenix/Phoenix.View.html" rel="noopener nofollow ugc"> <code>Phoenix.View</code> </a> module. Views also provide functions which take raw data and make it easier for templates to consume. If you are familiar with decorators or the facade pattern, this is similar.”</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="166394" data-batch-url="/posts/batch_likers">
                        2
                      </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/calling-view-file-functions-from-main-app/29572/12">Post #11</a>
	                </div>
	            </div>
              <div id="likers-container-166394" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="166394"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-most-liked cat-most-liked" title="One of the top 3 liked posts in this thread!"></div>
  </section>
</div>
    <div class="postbit" id="166396" data-post-id="166396">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Picking the right CSS class for given application state, conditionally showing username or “not logged in”, fiddling around with consistent CSS classes for inputs/buttons etc is something that I would put in a view module.</p>
<p>Also one-off stuff, like expanding a list in your assigns into a comma-separated list for display.</p>
<p>I see it as the final step to tidy things up so template code is more readable.</p>
<p>On the Phoenix <a href="https://hexdocs.pm/phoenix/overview.html" rel="noopener nofollow ugc">docs overview page</a>, the list is a little more terse than the description above:</p>
<ul>
<li>render templates</li>
<li>act as a presentation layer</li>
<li>define helper functions, available in templates, to decorate data for presentation</li>
</ul>
<p>Things like formatting phone numbers, addresses, currency etc are probably more business related. They can end up in email notifications, data exports, reports etc. They would most likely live in the app data modules (as per <a class="mention" href="/u/lud" rel="nofollow">@lud</a> suggestion) or in other modules depending on their complexity.</p>
<p>Ultimately here’s no hard and fast rules. One of the nice things about functional programming is it makes it relatively easy to move things around as your application grows or you discover module dependencies that no longer make sense. You put something into a function and a formatted thing comes out with no unpredictable side effects, so you can move that function elsewhere with relative ease.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="166396" data-batch-url="/posts/batch_likers">
                        2
                      </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/calling-view-file-functions-from-main-app/29572/13">Post #12</a>
	                </div>
	            </div>
              <div id="likers-container-166396" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="166396"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-solved cat-solved" title="Marked as solution"></div>
  </section>
</div>
    <div class="postbit" id="166397" data-post-id="166397">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="jmurphyweb" src="/assets/icons/user-9f439610.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  jmurphyweb
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>That is really useful. Thanks a lot for the reply.</p>
<p>I’ll have a look at my View modules this week to see if/how I can implement what you are pointing out here.</p>
<p>Thanks again!</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="166397" data-batch-url="/posts/batch_likers">
                        0
                      </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/calling-view-file-functions-from-main-app/29572/14">Post #13</a>
	                </div>
	            </div>
              <div id="likers-container-166397" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="166397"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #13"></div>
  </section>
</div>
    <div class="postbit" id="166398" data-post-id="166398">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="jmurphyweb" data-post="11" data-topic="29572">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/letter_avatar_proxy/v4/letter/j/f19dbf/48.png" class="avatar"> jmurphyweb:</div>
<blockquote>
<p>It sounds like you are saying the View modules are specifically for putting controller/context provided data into a shape that a template will readily consume. Is that pretty much it?</p>
</blockquote>
</aside>
<p><a class="mention" href="/u/mindok" rel="nofollow">@mindok</a> Already gave you an excellent explanation. I’ll just echo it by saying that stuff that people put in their Phoenix Views sometimes don’t serve their main goal of rendering HTML / JSON / other web stuff.</p>
<p>I think it’s quite OK to have modules like <code>MyApp.Data.CSV.Formatter</code> or <code>MyApp.Data.Salesforce.Importer</code>.</p>
<p>So the answer to your question is YES. Everything Phoenix must be <em>thin</em> – controllers, modules, views. Most of your business logic, data movement, validation, import/export, persistence, doesn’t belong in your Phoenix files.</p>
<p>As for stuff that <em>clearly</em> belongs in your web pages, there Views are in their exact territory of usage.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="166398" data-batch-url="/posts/batch_likers">
                        0
                      </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/calling-view-file-functions-from-main-app/29572/15">Post #14</a>
	                </div>
	            </div>
              <div id="likers-container-166398" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="166398"
                     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>