O'Reilly logo

Elixir Cookbook by Paulo A Pereira

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating views and templates

After the router determines the right controller and action to handle a request after the controller performs all the tasks to prepare data to respond to the request, it generally needs to output that data. In the previous recipe, we saw how a controller could respond by rendering test and outputting static HTML or even JSON. What if we need to generate an HTML response and that HTML must be dynamic, depending on the values passed by the controller?

Before we proceed, there is one thing we have to make clear for those coming from other frameworks: the view is not an HTML (or other markup) file. Views mainly render templates but they are also responsible for providing functions that make data easier to consume by templates. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required