# \#views

**URL:** https://forum.elixirforum.com/tag/views/659.md

[Latest](https://forum.elixirforum.com/latest.md) · [Categories](https://forum.elixirforum.com/categories.md) · [Tags](https://forum.elixirforum.com/tags.md)

---

## [Phoenix 1.7 - use Phoenix.Controller, layouts. Is the the :app layout used by default?](https://forum.elixirforum.com/t/phoenix-1-7-use-phoenix-controller-layouts-is-the-the-app-layout-used-by-default/62412)

<div class="topic-metadata">

**Author:** [@SussyAlchemist](https://forum.elixirforum.com/u/SussyAlchemist)\
**Replies:** 2\
**Last updated:** [March 20, 2024, 11:00pm UTC](https://forum.elixirforum.com/t/phoenix-1-7-use-phoenix-controller-layouts-is-the-the-app-layout-used-by-default/62412 "2024-03-20T23:00:47Z")

</div>

Hi everyone, I’m currently diving into Elixir and Phoenix, trying to grasp the inner workings of the framework. During my exploration, I came across the generated MyAppWeb module, particularly these two functions: def …

---

## [Phoenix Error Rendering & Multiple Endpoints](https://forum.elixirforum.com/t/phoenix-error-rendering-multiple-endpoints/59775)

<div class="topic-metadata">

**Author:** [@halostatue](https://forum.elixirforum.com/u/halostatue)\
**Replies:** 1\
**Last updated:** [November 16, 2023, 4:00pm UTC](https://forum.elixirforum.com/t/phoenix-error-rendering-multiple-endpoints/59775 "2023-11-16T16:00:13Z")

</div>

These are both likely a case of either “holding the tool wrong” or “using the wrong tool”, but I am looking for information and advice. We have built our Phoenix app in such a way that we have, excepting for ErrorView, …

---

## [Remove view layouts in favor of function components](https://forum.elixirforum.com/t/remove-view-layouts-in-favor-of-function-components/58290)

<div class="topic-metadata">

**Author:** [@rmoorman](https://forum.elixirforum.com/u/rmoorman)\
**Replies:** 9\
**Last updated:** [October 17, 2023, 8:44pm UTC](https://forum.elixirforum.com/t/remove-view-layouts-in-favor-of-function-components/58290 "2023-10-17T20:44:20Z")

</div>

Current situation Currently, the structure of the HTML returned by phoenix is determined by the layouts (components/layouts/\[root,app\].html.heex) as well as the template you select and render in the controller or livevie…

---

## [Call to missing or private function Phoenix.View.\_\_not\_found\_\_!/3.ElixirLS Dialyzer](https://forum.elixirforum.com/t/call-to-missing-or-private-function-phoenix-view-not-found-3-elixirls-dialyzer/57391)

<div class="topic-metadata">

**Author:** [@apoorv-2204](https://forum.elixirforum.com/u/apoorv-2204)\
**Replies:** 3\
**Last updated:** [August 2, 2023, 10:06am UTC](https://forum.elixirforum.com/t/call-to-missing-or-private-function-phoenix-view-not-found-3-elixirls-dialyzer/57391 "2023-08-02T10:06:13Z")

</div>

defmodule AdminWeb do @moduledoc """ The entrypoint for defining your web interface, such as controllers, views, channels and so on. This can be used in your application as: use AdminWeb, :controlle…

---

## [Asserting on the JSON response from a controller action in OTP26](https://forum.elixirforum.com/t/asserting-on-the-json-response-from-a-controller-action-in-otp26/56562)

<div class="topic-metadata">

**Author:** [@gmile](https://forum.elixirforum.com/u/gmile)\
**Replies:** 5\
**Last updated:** [June 18, 2023, 8:17am UTC](https://forum.elixirforum.com/t/asserting-on-the-json-response-from-a-controller-action-in-otp26/56562 "2023-06-18T08:17:19Z")

</div>

After upgrading to OTP26, we’re seeing a lot of failures related to the shape of JSON response. For example, given the view is constructed using atoms (which is how we do it), the following assertion easily fails: outpu…

---

## [\`Phoenix.View\` deprecation and multi-format endpoints](https://forum.elixirforum.com/t/phoenix-view-deprecation-and-multi-format-endpoints/51618)

<div class="topic-metadata">

**Author:** [@hauleth](https://forum.elixirforum.com/u/hauleth)\
**Replies:** 1\
**Last updated:** [December 25, 2022, 2:37am UTC](https://forum.elixirforum.com/t/phoenix-view-deprecation-and-multi-format-endpoints/51618 "2022-12-25T02:37:08Z")

</div>

I have looked into Phoenix.View deprecation and one thing seems worrying to me. The “new” approach with Phoenix.Component and “view functions” is lacking one important feature that I was using pretty extensively in my pr…

---

## [Respond with json string without render from :view or :controller](https://forum.elixirforum.com/t/respond-with-json-string-without-render-from-view-or-controller/50389)

<div class="topic-metadata">

**Author:** [@NaN](https://forum.elixirforum.com/u/NaN)\
**Replies:** 1\
**Last updated:** [September 20, 2022, 7:45am UTC](https://forum.elixirforum.com/t/respond-with-json-string-without-render-from-view-or-controller/50389 "2022-09-20T07:45:56Z")

</div>

Im receiving json from postgres. I dont want to deserialize as a map then serialize to json. Im using using rustler to query the database in rust. Which returns a string. I would like to then just pass that string back …

---

## [(FunctionClauseError) no function clause matching in anonymous fn/1 in EEx.Compiler.tokenize/6](https://forum.elixirforum.com/t/functionclauseerror-no-function-clause-matching-in-anonymous-fn-1-in-eex-compiler-tokenize-6/50273)

<div class="topic-metadata">

**Author:** [@mayulu](https://forum.elixirforum.com/u/mayulu)\
**Replies:** 3\
**Last updated:** [September 19, 2022, 8:10am UTC](https://forum.elixirforum.com/t/functionclauseerror-no-function-clause-matching-in-anonymous-fn-1-in-eex-compiler-tokenize-6/50273 "2022-09-19T08:10:28Z")

</div>

My project works under Phoenix1.6.6. After upgraded to 1.6.12, It compiled error, and I cannot understand the compilation result information, as followed: == Compilation error in file lib/linlang\_web/views/user\_session\_…

---

## [How to customize view when ip was banned by paraxial.io?](https://forum.elixirforum.com/t/how-to-customize-view-when-ip-was-banned-by-paraxial-io/49776)

<div class="topic-metadata">

**Author:** [@Hasimbola](https://forum.elixirforum.com/u/Hasimbola)\
**Replies:** 0\
**Last updated:** [August 25, 2022, 7:54am UTC](https://forum.elixirforum.com/t/how-to-customize-view-when-ip-was-banned-by-paraxial-io/49776 "2022-08-25T07:54:11Z")

</div>

Good morning evrybody, I want to ask how to change this view please? I've try to use error\_view to render another template but it doen't work, Can someone help me? thanks a lot This is the error when the ip were ban…

---

## [Possible to use Phoenix.View with non-compiled HTML templates?](https://forum.elixirforum.com/t/possible-to-use-phoenix-view-with-non-compiled-html-templates/46885)

<div class="topic-metadata">

**Author:** [@dcrck](https://forum.elixirforum.com/u/dcrck)\
**Replies:** 9\
**Last updated:** [March 30, 2022, 1:17pm UTC](https://forum.elixirforum.com/t/possible-to-use-phoenix-view-with-non-compiled-html-templates/46885 "2022-03-30T13:17:49Z")

</div>

Hi, I’m working on a project that requires generating and serving a (potentially large) number of static HTML files. Since the project also uses Phoenix, I’d like to take advantage of Phoenix’s ability to quickly render …

---

## [Rendering components from a view](https://forum.elixirforum.com/t/rendering-components-from-a-view/45923)

<div class="topic-metadata">

**Author:** [@sbaildon](https://forum.elixirforum.com/u/sbaildon)\
**Replies:** 3\
**Last updated:** [February 9, 2022, 10:02pm UTC](https://forum.elixirforum.com/t/rendering-components-from-a-view/45923 "2022-02-09T22:02:32Z")

</div>

I want to render a list of widgets where each one has a trailing static element, except the last \<div class="widget"\> \<br\> \<div class="widget"\> \<br\> \<div class="widget"\> Comprehensions in templates make it a little tri…

---

## [How to get \`@view\_module\` from a layout with Phoenix.View 1.0.0](https://forum.elixirforum.com/t/how-to-get-view-module-from-a-layout-with-phoenix-view-1-0-0/43448)

<div class="topic-metadata">

**Author:** [@marcandre](https://forum.elixirforum.com/u/marcandre)\
**Replies:** 7\
**Last updated:** [December 30, 2021, 3:59pm UTC](https://forum.elixirforum.com/t/how-to-get-view-module-from-a-layout-with-phoenix-view-1-0-0/43448 "2021-12-30T15:59:37Z")

</div>

While Phoenix.View#render/3 used to set @view\_module and @view\_template for us to be used within the layout. WIth the newer Phoenix.View 1.0.0, is there a way to access this information? From the doc and the source, i…

---

## [Error rendering view, implementing the many function](https://forum.elixirforum.com/t/error-rendering-view-implementing-the-many-function/44382)

<div class="topic-metadata">

**Author:** [@hector97rch](https://forum.elixirforum.com/u/hector97rch)\
**Replies:** 3\
**Last updated:** [December 10, 2021, 7:08pm UTC](https://forum.elixirforum.com/t/error-rendering-view-implementing-the-many-function/44382 "2021-12-10T19:08:11Z")

</div>

Hi I’m new to elixir and I have a problem when i render one view using many, all of this happens when I call get\_users the error its this: # Could not render "usuario.json" for UsuariosWeb.UserView, please define a matc…

---

## [Error in file view but there's no code in that view, how can I fix this?](https://forum.elixirforum.com/t/error-in-file-view-but-theres-no-code-in-that-view-how-can-i-fix-this/43165)

<div class="topic-metadata">

**Author:** [@dstpierre](https://forum.elixirforum.com/u/dstpierre)\
**Replies:** 6\
**Last updated:** [October 18, 2021, 8:53pm UTC](https://forum.elixirforum.com/t/error-in-file-view-but-theres-no-code-in-that-view-how-can-i-fix-this/43165 "2021-10-18T20:53:00Z")

</div>

Hello there, I’m getting this error: Compiling 3 files (.ex) == Compilation error in file lib/xyz\_web/views/settings\_view.ex == \*\* (SyntaxError) nofile:6:51: syntax error before: "info" (phoenix\_live\_view 0.16.4) …

---

## [Should API Server only provide information which is required by front-end as a response?](https://forum.elixirforum.com/t/should-api-server-only-provide-information-which-is-required-by-front-end-as-a-response/43138)

<div class="topic-metadata">

**Author:** [@Papillon6814](https://forum.elixirforum.com/u/Papillon6814)\
**Replies:** 2\
**Last updated:** [October 18, 2021, 1:12am UTC](https://forum.elixirforum.com/t/should-api-server-only-provide-information-which-is-required-by-front-end-as-a-response/43138 "2021-10-18T01:12:09Z")

</div>

Hello. I have a question about design of phoenix api server. I am developing a web application, and using phoenix as a backend server for it. I saw some open source repositories as examples, but I still don’t know what …

---

## [Set active Bootstrap navbar item with Phoenix](https://forum.elixirforum.com/t/set-active-bootstrap-navbar-item-with-phoenix/32773)

<div class="topic-metadata">

**Author:** [@zizheng](https://forum.elixirforum.com/u/zizheng)\
**Replies:** 7\
**Last updated:** [June 22, 2021, 6:32pm UTC](https://forum.elixirforum.com/t/set-active-bootstrap-navbar-item-with-phoenix/32773 "2021-06-22T18:32:23Z")

</div>

Hi all, I’m using Phoenix with Bootstrap and I’m having some trouble figuring out the best way to set the active navbar item. In Bootstrap, adding the "active" class to a nav item sets it as the current nav item. My goa…

---

## [Protocol String.Chars not implemented when rendering a partial template](https://forum.elixirforum.com/t/protocol-string-chars-not-implemented-when-rendering-a-partial-template/40457)

<div class="topic-metadata">

**Author:** [@silverdr](https://forum.elixirforum.com/u/silverdr)\
**Replies:** 2\
**Last updated:** [June 15, 2021, 3:07pm UTC](https://forum.elixirforum.com/t/protocol-string-chars-not-implemented-when-rendering-a-partial-template/40457 "2021-06-15T15:07:21Z")

</div>

I followed this nice post to set rendering of shared partials across Phoenix application up. Now I must be doing something obviously erroneous because whenever I try to render any of the shared templates I get protocol …

---

## [Not understanding why my put\_layout(false) does not remote the root.html layout?](https://forum.elixirforum.com/t/not-understanding-why-my-put-layout-false-does-not-remote-the-root-html-layout/33297)

<div class="topic-metadata">

**Author:** [@dstpierre](https://forum.elixirforum.com/u/dstpierre)\
**Replies:** 2\
**Last updated:** [June 13, 2021, 8:56pm UTC](https://forum.elixirforum.com/t/not-understanding-why-my-put-layout-false-does-not-remote-the-root-html-layout/33297 "2021-06-13T20:56:12Z")

</div>

Hi, Retrying Elixir for the 4th time in the last 3 years, I think this time will be the “good” one. So I’m still just playing around, and would need an explanation about why a fresh controller with the following action…

---

## [What's the best solution for reusable view components?](https://forum.elixirforum.com/t/whats-the-best-solution-for-reusable-view-components/31667)

<div class="topic-metadata">

**Author:** [@ketzo](https://forum.elixirforum.com/u/ketzo)\
**Replies:** 2\
**Last updated:** [June 12, 2021, 3:52pm UTC](https://forum.elixirforum.com/t/whats-the-best-solution-for-reusable-view-components/31667 "2021-06-12T15:52:48Z")

</div>

I’ve got two models, Chores and Users, as part of a little chore-tracking CRUD app. When you go to the index route for either model, I display all the entries in pretty similar forms: a \<table\> with a \<th\> row and each d…

---

## [Efficient & idiomatic way of rendering Json inside HTML template in Phoenix](https://forum.elixirforum.com/t/efficient-idiomatic-way-of-rendering-json-inside-html-template-in-phoenix/39856)

<div class="topic-metadata">

**Author:** [@adrian](https://forum.elixirforum.com/u/adrian)\
**Replies:** 3\
**Last updated:** [May 21, 2021, 6:23am UTC](https://forum.elixirforum.com/t/efficient-idiomatic-way-of-rendering-json-inside-html-template-in-phoenix/39856 "2021-05-21T06:23:53Z")

</div>

Hello, I’m trying to render a Json with microformat data in the root of the template. Initially I did it writing the json in a template, but it seems inneficient, and buggy: \<script type="application/ld+json"\> { "@c…

---

## [Rendering a Dictionary In JSON](https://forum.elixirforum.com/t/rendering-a-dictionary-in-json/39623)

<div class="topic-metadata">

**Author:** [@F17CH](https://forum.elixirforum.com/u/F17CH)\
**Replies:** 1\
**Last updated:** [May 13, 2021, 12:19am UTC](https://forum.elixirforum.com/t/rendering-a-dictionary-in-json/39623 "2021-05-13T00:19:27Z")

</div>

Hi All, Appreciate any help on this issue, new to elixir so please feel free to point anything obvious I am doing wrong below. I am trying to render a custom map inside a phoenix view, much like how you would represent…

---

## [Block database queries from view layer](https://forum.elixirforum.com/t/block-database-queries-from-view-layer/37464)

<div class="topic-metadata">

**Author:** [@baldwindavid](https://forum.elixirforum.com/u/baldwindavid)\
**Replies:** 5\
**Last updated:** [February 11, 2021, 1:43am UTC](https://forum.elixirforum.com/t/block-database-queries-from-view-layer/37464 "2021-02-11T01:43:06Z")

</div>

Is there any way to block database queries stemming from the View layer? I have a permit? function that can be called in a template that delegates to authorization logic in my domain layer. This is usually fine, but the…

---

## [Cryptic "undefined function arg0/0" error message in EEx templates](https://forum.elixirforum.com/t/cryptic-undefined-function-arg0-0-error-message-in-eex-templates/37268)

<div class="topic-metadata">

**Author:** [@thiagomajesk](https://forum.elixirforum.com/u/thiagomajesk)\
**Replies:** 8\
**Last updated:** [February 5, 2021, 8:30pm UTC](https://forum.elixirforum.com/t/cryptic-undefined-function-arg0-0-error-message-in-eex-templates/37268 "2021-02-05T20:30:12Z")

</div>

Hi! I’m working on this small lib that provides a structure to better organize components on top of Phoenix’s views (influenced by AspNet’s and Ruby’s ViewComponents)… I was testing some use-cases today and got this com…

---

## [Examples of using view models in Phoenix?](https://forum.elixirforum.com/t/examples-of-using-view-models-in-phoenix/34350)

<div class="topic-metadata">

**Author:** [@marick](https://forum.elixirforum.com/u/marick)\
**Replies:** 1\
**Last updated:** [September 14, 2020, 6:55am UTC](https://forum.elixirforum.com/t/examples-of-using-view-models-in-phoenix/34350 "2020-09-14T06:55:35Z")

</div>

TLDR: Can you point me to writeups or examples of using “view models” in Phoenix apps? I found myself getting confused using a single Ecto Schema to handle all of form validation, database constraints, translation of n…

---

## [Compiling of views taking lit of time during development](https://forum.elixirforum.com/t/compiling-of-views-taking-lit-of-time-during-development/32768)

<div class="topic-metadata">

**Author:** [@santoshbt](https://forum.elixirforum.com/u/santoshbt)\
**Replies:** 7\
**Last updated:** [July 1, 2020, 11:26am UTC](https://forum.elixirforum.com/t/compiling-of-views-taking-lit-of-time-during-development/32768 "2020-07-01T11:26:00Z")

</div>

Whenever mix phx.server is running, if I make any small changes to anywhere in the controller (even which is completely isolated), all the view files start compiling once again. So everytime I need to test something, it …

---

## [Gettext.extract not consider views](https://forum.elixirforum.com/t/gettext-extract-not-consider-views/32533)

<div class="topic-metadata">

**Author:** [@romaluca](https://forum.elixirforum.com/u/romaluca)\
**Replies:** 4\
**Last updated:** [June 23, 2020, 7:58am UTC](https://forum.elixirforum.com/t/gettext-extract-not-consider-views/32533 "2020-06-23T07:58:48Z")

</div>

In a view of my project i have this method: def page\_title(:new, assigns) do if is\_nil(assigns.changeset.data.contest\_id) do Gettext.gettext(ShuttertopWeb.Gettext, "Nuovo contest") else "#{assigns.ch…

---

## [Live View migration 0.7.x to 0.13.2](https://forum.elixirforum.com/t/live-view-migration-0-7-x-to-0-13-2/32035)

<div class="topic-metadata">

**Author:** [@kaquadu](https://forum.elixirforum.com/u/kaquadu)\
**Replies:** 0\
**Last updated:** [June 2, 2020, 2:57pm UTC](https://forum.elixirforum.com/t/live-view-migration-0-7-x-to-0-13-2/32035 "2020-06-02T14:57:23Z")

</div>

Hello guys, I’ve got a question about updating Live View from older versions to the newest one. New versions of Live View are using different layouts for live templates, which means we need to create one. The problem is…

---

## [Make logged user available in nested view model](https://forum.elixirforum.com/t/make-logged-user-available-in-nested-view-model/30232)

<div class="topic-metadata">

**Author:** [@benonymus](https://forum.elixirforum.com/u/benonymus)\
**Replies:** 0\
**Last updated:** [March 31, 2020, 2:08am UTC](https://forum.elixirforum.com/t/make-logged-user-available-in-nested-view-model/30232 "2020-03-31T02:08:08Z")

</div>

Hey there, I have a user view model that has a field called is\_friend. This returns true or false depending on if the logged user is a friend of the user in question. This user model is a nested model, and being used …

---

## [Calling View file functions from main app](https://forum.elixirforum.com/t/calling-view-file-functions-from-main-app/29572)

<div class="topic-metadata">

**Author:** [@jmurphyweb](https://forum.elixirforum.com/u/jmurphyweb)\
**Replies:** 14\
**Last updated:** [March 8, 2020, 11:04am UTC](https://forum.elixirforum.com/t/calling-view-file-functions-from-main-app/29572 "2020-03-08T11:04:09Z")

</div>

Given that View modules contain formatting logic, what do you do if you want to format some data in your main application (ie in lib/myapp/ as opposed to in the lib/myapp\_web/) ? We are doing a load of CSV exports, and …

---

## [How string interpolation is done within the error messages of changesets (using %{})?](https://forum.elixirforum.com/t/how-string-interpolation-is-done-within-the-error-messages-of-changesets-using/29601)

<div class="topic-metadata">

**Author:** [@Sanjibukai](https://forum.elixirforum.com/u/Sanjibukai)\
**Replies:** 7\
**Last updated:** [March 4, 2020, 11:49pm UTC](https://forum.elixirforum.com/t/how-string-interpolation-is-done-within-the-error-messages-of-changesets-using/29601 "2020-03-04T23:49:51Z")

</div>

Hello everybody, When I look at what an error looks like in a Changeset, it’s something like this: \[username: {"should be at most %{count} character(s)", \[count: 20, validation: :length, kind: :max, type: :string\]}\] # …

[Next page](https://forum.elixirforum.com/tag/views/659.md?match_all_tags=true&page=1&tags%5B%5D=views)
