nova
nova copied to clipboard
Update guides to explain more about views and controllers
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]}}