@@ -8,18 +8,15 @@ methods from models to presenters.
...
@@ -8,18 +8,15 @@ methods from models to presenters.
### When your view is full of logic
### When your view is full of logic
When your view is full of logic (`if`, `else`, `select` on arrays etc.), it's time
When your view is full of logic (`if`, `else`, `select` on arrays etc.), it's
to create a presenter!
time to create a presenter!
For instance this view is full of logic: https://gitlab.com/gitlab-org/gitlab-ce/blob/d61f8a18e0f7e9d0ed162827f4e8ae2de3756f5c/app/views/projects/builds/_sidebar.html.haml
can be improved as follows: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/7073/diffs
### When your model has a lot of view-related logic/data methods
### When your model has a lot of view-related logic/data methods
When your model has a lot of view-related logic/data methods, you can easily
When your model has a lot of view-related logic/data methods, you can easily
move them to a presenter.
move them to a presenter.
## Why using presenters instead of helpers?
## Why are we using presenters instead of helpers?
We don't use presenters to generate complex view output that would rely on helpers.
We don't use presenters to generate complex view output that would rely on helpers.
...
@@ -28,11 +25,11 @@ Presenters should be used for:
...
@@ -28,11 +25,11 @@ Presenters should be used for:
- Data and logic methods that can be pulled & combined into single methods from
- Data and logic methods that can be pulled & combined into single methods from
view. This can include loops extracted from views too. A good example is
view. This can include loops extracted from views too. A good example is