mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-31 21:37:16 +00:00
Convert most templates from erb to haml
This commit is contained in:
@@ -1,19 +0,0 @@
|
||||
<% filters = @taxon ? @taxon.applicable_filters : [] %>
|
||||
<% unless filters.empty? %>
|
||||
<nav id="filters">
|
||||
<% params[:search] ||= {} %>
|
||||
<% filters.each do |filter| %>
|
||||
<% labels = filter[:labels] || filter[:conds].map {|m,c| [m,m]} %>
|
||||
<% next if labels.empty? %>
|
||||
<h6 class="filter_name">Shop by <%= filter[:name] %></h6>
|
||||
<ul class="filter_choices">
|
||||
<% labels.each do |nm,val| %>
|
||||
<li class="nowrap">
|
||||
<% active = params[:search][filter[:scope]] && params[:search][filter[:scope]].include?(val.to_s) %>
|
||||
<%= link_to nm, "?search[#{filter[:scope].to_s}][]=#{CGI.escape(val)}" %>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
<% end %>
|
||||
</nav>
|
||||
<% end %>
|
||||
15
app/views/spree/shared/_filters.html.haml
Normal file
15
app/views/spree/shared/_filters.html.haml
Normal file
@@ -0,0 +1,15 @@
|
||||
- filters = @taxon ? @taxon.applicable_filters : []
|
||||
- unless filters.empty?
|
||||
%nav#filters
|
||||
- params[:search] ||= {}
|
||||
- filters.each do |filter|
|
||||
- labels = filter[:labels] || filter[:conds].map {|m,c| [m,m]}
|
||||
- next if labels.empty?
|
||||
|
||||
%h6.filter_name= "Shop by #{filter[:name]}"
|
||||
|
||||
%ul.filter_choices
|
||||
- labels.each do |nm,val|
|
||||
%li.nowrap
|
||||
- active = params[:search][filter[:scope]] && params[:search][filter[:scope]].include?(val.to_s)
|
||||
= link_to nm, "?search[#{filter[:scope].to_s}][]=#{CGI.escape(val)}"
|
||||
@@ -1,31 +0,0 @@
|
||||
<%
|
||||
paginated_products = @searcher.retrieve_products if params.key?(:keywords)
|
||||
paginated_products ||= products
|
||||
%>
|
||||
<% if products.empty? %>
|
||||
<%= t(:no_products_found) %>
|
||||
<% elsif params.key?(:keywords) %>
|
||||
<h6 class="search-results-title"><%= t(:search_results, :keywords => h(params[:keywords])) %></h6>
|
||||
<% end %>
|
||||
|
||||
<% if products.any? %>
|
||||
<ul class="inline product-listing" data-hook>
|
||||
<% reset_cycle('default') %>
|
||||
<% products.each do |product| %>
|
||||
<% if Spree::Config[:show_zero_stock_products] || product.has_stock? %>
|
||||
<li id="product_<%= product.id %>" class="columns three <%= cycle("alpha", "secondary", "", "omega secondary") %>" data-hook="products_list_item" itemscope itemtype="http://schema.org/Product">
|
||||
<div class="product-image">
|
||||
<%= link_to small_image(product, :itemprop => "image"), product, :itemprop => 'url' %>
|
||||
</div>
|
||||
<%= link_to truncate(product.name, :length => 50), product, :class => 'info', :itemprop => "name", :title => product.name %>
|
||||
<span class="price selling" itemprop="price"><%= number_to_currency product.price %></span>
|
||||
</li>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</ul>
|
||||
<% end %>
|
||||
|
||||
<% if paginated_products.respond_to?(:num_pages)
|
||||
params.delete(:search)
|
||||
params.delete(:taxon)
|
||||
%><%= paginate paginated_products %><% end %>
|
||||
23
app/views/spree/shared/_products.html.haml
Normal file
23
app/views/spree/shared/_products.html.haml
Normal file
@@ -0,0 +1,23 @@
|
||||
- paginated_products = @searcher.retrieve_products if params.key?(:keywords)
|
||||
- paginated_products ||= products
|
||||
|
||||
- if products.empty?
|
||||
= t(:no_products_found)
|
||||
- elsif params.key?(:keywords)
|
||||
%h6.search-results-title= t(:search_results, :keywords => h(params[:keywords]))
|
||||
|
||||
- if products.any?
|
||||
%ul.inline.product-listing{"data-hook" => ""}
|
||||
- reset_cycle('default')
|
||||
- products.each do |product|
|
||||
- if Spree::Config[:show_zero_stock_products] || product.has_stock?
|
||||
%li{:class => "columns three #{cycle("alpha", "secondary", "", "omega secondary")}", "data-hook" => "products_list_item", :id => "product_#{product.id}", :itemscope => "", :itemtype => "http://schema.org/Product"}
|
||||
.product-image
|
||||
= link_to small_image(product, :itemprop => "image"), product, :itemprop => 'url'
|
||||
= link_to truncate(product.name, :length => 50), product, :class => 'info', :itemprop => "name", :title => product.name
|
||||
%span.price.selling{:itemprop => "price"}= number_to_currency product.price
|
||||
|
||||
- if paginated_products.respond_to?(:num_pages)
|
||||
- params.delete(:search)
|
||||
- params.delete(:taxon)
|
||||
= paginate paginated_products
|
||||
Reference in New Issue
Block a user