nova icon indicating copy to clipboard operation
nova copied to clipboard

Update guides to explain more about views and controllers

Open Taure opened this issue 2 years ago • 0 comments

Yes. So it comes from endpoint in the routing file that points to a controller. If the function in that controller returns {ok, Variables} Nova will render the view with same name like you mentioned. If you want to create a new controller you can do that with a new view with same name combination. And you will have more views.

If you want to have say one view to list users and one view to list one user profile you can do it in same controller but point to the function in the routing file. Then use tuple with three elements.

user_list.dtl user_profile.dtl

list_users(_) -> {ok, Variables, #{view => user_list}}

user_profile(_) -> {ok, Variables, #{view => user_profile}}

Routing could be like: {"/user", {my_user_controller, list_users}, #{methods => [get]}} {"/user/:userid", {my_user_controller, user_profile}, #{methods => [get]}}

Taure avatar Mar 02 '22 16:03 Taure