Conditionally render templates in Phoenix - Elixir

Sometimes in a Phoenix Framework project, you want to conditionally render a template. Why not just use a "cond" or "case" or a bunch of "if" statements?

Well, i'm lazy, is the short answer.

But the long answer is that i want to just add new templates, which is just like adding new functionality. And if I don't have that functionality, I just drop back to a default EEX template.

The handy "render_existing" function handles this very well, but it's not so obvious in the documentation.

And there you have it. Simple conditional template rendering in Phoenix Framework.


  1. How much of the "Programming Elixir" book must I go through before I can start learning Phoenix?
  2. What popular or emerging web applications are built with the Elixir language and Phoenix framework?
  3. How do I learn Phoenix (Elixir) in a pleasant way?
  4. Is it possible to build an eCommerce website with Elixir and the Phoenix framework?
  5. Is Elixir + Phoenix worth learning when you have to create very quickly web backends that scale to millions of users?
  6. How mature is Elixir?
  7. Is Elixir (programming language) dying?
  8. As a Ruby programmer, why do you choose Elixir over Crystal or vice versa?