Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update guides to explain more about views and controllers #170

Closed
Taure opened this issue Mar 2, 2022 · 1 comment
Closed

Update guides to explain more about views and controllers #170

Taure opened this issue Mar 2, 2022 · 1 comment
Labels
documentation Improvements or additions to documentation good first issue Good for newcomers help wanted Extra attention is needed

Comments

@Taure
Copy link
Collaborator

Taure commented Mar 2, 2022

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 Taure added documentation Improvements or additions to documentation help wanted Extra attention is needed good first issue Good for newcomers labels Mar 2, 2022
@burbas
Copy link
Contributor

burbas commented Oct 14, 2022

Documentation for controllers and views (Atleast partially) have been updated. (PR #191). Closing this issue

@burbas burbas closed this as completed Oct 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants