From 6cd9bff29ffbdfd3c22591a53430ee94cae34967 Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Mon, 25 Jun 2012 09:06:56 +1000 Subject: [PATCH] Convert most templates from erb to haml --- app/views/spree/shared/_filters.html.erb | 19 ------------- app/views/spree/shared/_filters.html.haml | 15 +++++++++++ app/views/spree/shared/_products.html.erb | 31 ---------------------- app/views/spree/shared/_products.html.haml | 23 ++++++++++++++++ 4 files changed, 38 insertions(+), 50 deletions(-) delete mode 100644 app/views/spree/shared/_filters.html.erb create mode 100644 app/views/spree/shared/_filters.html.haml delete mode 100644 app/views/spree/shared/_products.html.erb create mode 100644 app/views/spree/shared/_products.html.haml diff --git a/app/views/spree/shared/_filters.html.erb b/app/views/spree/shared/_filters.html.erb deleted file mode 100644 index b2e89c205c..0000000000 --- a/app/views/spree/shared/_filters.html.erb +++ /dev/null @@ -1,19 +0,0 @@ -<% filters = @taxon ? @taxon.applicable_filters : [] %> -<% unless filters.empty? %> - -<% end %> diff --git a/app/views/spree/shared/_filters.html.haml b/app/views/spree/shared/_filters.html.haml new file mode 100644 index 0000000000..728dbbc0ef --- /dev/null +++ b/app/views/spree/shared/_filters.html.haml @@ -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)}" diff --git a/app/views/spree/shared/_products.html.erb b/app/views/spree/shared/_products.html.erb deleted file mode 100644 index 0d633e7415..0000000000 --- a/app/views/spree/shared/_products.html.erb +++ /dev/null @@ -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) %> -
<%= t(:search_results, :keywords => h(params[:keywords])) %>
-<% end %> - -<% if products.any? %> - -<% end %> - -<% if paginated_products.respond_to?(:num_pages) - params.delete(:search) - params.delete(:taxon) -%><%= paginate paginated_products %><% end %> diff --git a/app/views/spree/shared/_products.html.haml b/app/views/spree/shared/_products.html.haml new file mode 100644 index 0000000000..9b1e421009 --- /dev/null +++ b/app/views/spree/shared/_products.html.haml @@ -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