biontext.blogg.se

Name bag templates for pages
Name bag templates for pages




For example, if you define a function in your view, you will be able to invoke it directly from the template. That's because templates are effectively compiled into functions inside their respective views. This line calls the view/0 function defined in HelloWeb which sets up the basic imports and configuration for our views and templates.Īll of the imports and aliases we make in our view will also be available in our templates. There's only one line, use HelloWeb, :view.

name bag templates for pages

defmodule HelloWeb.LayoutView do use HelloWeb, :view end While all of these can be customizable (see Phoenix.View and Phoenix.Template for more information), we recommend users stick with Phoenix' convention.Ī newly generated Phoenix application has three view modules - ErrorView, LayoutView, and PageView - which are all in the lib/hello_web/views/ directory. PageController requires a PageView to render templates in the lib/hello_web/templates/page/ directory. Phoenix assumes a strong naming convention from controllers to views to the templates they render. Most of the time, we use templates to build these responses, but we can also craft them by hand. The main job of a Phoenix view is to render the body of the response which gets sent back to browsers and to API clients.

name bag templates for pages

Requirement: This guide expects that you have gone through the request life-cycle guide. Requirement: This guide expects that you have gone through the introductory guides and got a Phoenix application up and running.






Name bag templates for pages