app/views/administrate/application/index.html.erb in administrate-0.0.12 vs app/views/administrate/application/index.html.erb in administrate-0.1.0
- old
+ new
@@ -1,30 +1,55 @@
+<%#
+# Index
+
+This view is the template for the index page.
+It is responsible for rendering the search bar, header and pagination.
+It renders the `_table` partial to display details about the resources.
+
+## Local variables:
+
+- `page`:
+ An instance of [Administrate::Page::Table][1].
+ Contains helper methods to help display a table,
+ and knows which attributes should be displayed in the resource's table.
+- `resources`:
+ An instance of `ActiveRecord::Relation` containing the resources
+ that match the user's search criteria.
+ By default, these resources are passed to the table partial to be displayed.
+- `search_term`:
+ A string containing the term the user has searched for, if any.
+
+[1]: http://www.rubydoc.info/gems/administrate/Administrate/Page/Table
+%>
+
+<% content_for(:title) { page.resource_name.pluralize.titleize } %>
+
<% content_for(:search) do %>
<form class="search">
<span class="search__icon">
<%= inline_svg "administrate/search.svg" %>
</span>
<input
type="text"
name="search"
class="search__input"
placeholder="Search"
- value="<%= @search_term %>"
+ value="<%= search_term %>"
/>
<span class="search__hint">
Press enter to search
</span>
</form>
<% end %>
<header class="header">
- <h1 class="header-heading"><%= @page.resource_name.pluralize.titleize %></h1>
+ <h1 class="header-heading"><%= content_for(:title) %></h1>
<%= link_to(
- "New #{@page.resource_name.titleize.downcase}",
- [:new, Administrate::NAMESPACE, @page.resource_name],
+ "New #{page.resource_name.titleize.downcase}",
+ [:new, Administrate::NAMESPACE, page.resource_name],
class: "button",
) %>
</header>
-<%= render "table", table_presenter: @page, resources: @resources %>
+<%= render "collection", collection_presenter: page, resources: resources %>
-<%= paginate @resources %>
+<%= paginate resources %>