Upgrade to Pro — share decks privately, control downloads, hide ads and more …

SpreeConf 2012: Spree themes with Deface

Brian Quinn
February 19, 2012

SpreeConf 2012: Spree themes with Deface

Overview of Spree's new core theme, and a deep dive into Deface.

Brian Quinn

February 19, 2012
Tweet

More Decks by Brian Quinn

Other Decks in Technology

Transcript

  1. We’re going to cover • Intro to themes • Theme

    design principals • Walkthrough the core base theme • Deep dive into Deface • Features • Internals • Examples • Tricks • The future!
  2. Going to presume • You’re a Rails Developer • You’re

    comfortable with HTML, CSS • You’ve already worked with Spree • You’ll stop me if you have a question!
  3. 1 2 3 4 5 6 7 8 9 10

    11 12 13 14 15 16
  4. 4

  5. 12

  6. 3

  7. 6

  8. 10

  9. 16

  10. <div id="wrapper" class="row" data-hook> <% if content_for?(:sidebar) %> <aside id="sidebar"

    class="four columns alpha" data-hook> <%= yield :sidebar %> </aside> <% end %> 4 Skeleton app/views/spree/layouts/spree_application.html.erb 1 2 3 4 5 6 7
  11. <div id="wrapper" class="row" data-hook> <% if content_for?(:sidebar) %> <aside id="sidebar"

    class="four columns alpha" data-hook> <%= yield :sidebar %> </aside> <% end %> 4 Skeleton app/views/spree/layouts/spree_application.html.erb 1 2 3 4 5 6 7
  12. <div id="wrapper" class="row" data-hook> <% if content_for?(:sidebar) %> <aside id="sidebar"

    class="four columns alpha" data-hook> <%= yield :sidebar %> </aside> <% end %> 4 Skeleton app/views/spree/layouts/spree_application.html.erb 1 2 3 4 5 6 7
  13. /* Mobile Landscape Size to Tablet Portrait (devices and browsers)

    */ @media only screen and (min-width: 480px) and (max-width: 767px) { ul#products { margin-left: 0; margin-right: -20px; li { width: 133px; margin-right: 10px; } } Media Query core/app/assets/stylesheets/store/screen.css.scss
  14. /* Mobile Landscape Size to Tablet Portrait (devices and browsers)

    */ @media only screen and (min-width: 480px) and (max-width: 767px) { ul#products { margin-left: 0; margin-right: -20px; li { width: 133px; margin-right: 10px; } } Media Query core/app/assets/stylesheets/store/screen.css.scss
  15. /* Mobile Landscape Size to Tablet Portrait (devices and browsers)

    */ @media only screen and (min-width: 480px) and (max-width: 767px) { ul#products { margin-left: 0; margin-right: -20px; li { width: 133px; margin-right: 10px; } } Media Query core/app/assets/stylesheets/store/screen.css.scss
  16. /* Mobile Landscape Size to Tablet Portrait (devices and browsers)

    */ @media only screen and (max-width: 479px) { ul#products { margin-left: 0; margin-right: -20px; li { width: 140px; margin-right: 10px; } } Media Query core/app/assets/stylesheets/store/screen.css.scss
  17. /* Mobile Landscape Size to Tablet Portrait (devices and browsers)

    */ @media only screen and (max-width: 479px) { ul#products { margin-left: 0; margin-right: -20px; li { width: 140px; margin-right: 10px; } } Media Query core/app/assets/stylesheets/store/screen.css.scss
  18. /* Mobile Landscape Size to Tablet Portrait (devices and browsers)

    */ @media only screen and (max-width: 479px) { ul#products { margin-left: 0; margin-right: -20px; li { width: 140px; margin-right: 10px; } } Media Query core/app/assets/stylesheets/store/screen.css.scss
  19. <div id="thumbnails" data-hook> <% if @product.present? %> <%= render :partial

    => 'thumbnails' %> <% end %> </div> Original ERB 1 2 3 4 5
  20. <div id="thumbnails" data-hook> <% if @product.present? %> <%= render :partial

    => 'thumbnails' %> <% end %> </div> Original ERB Pseudo ERB / XML <div id="thumbnails" data-hook> <code erb-silent> if @product.present? </code> <code erb-loud> render :partial => 'thumbnails' </code> <code erb-silent> end </code> </div> 1 2 3 4 5 1 2 3 4 5
  21. <div id="thumbnails" data-hook> <% if @product.present? %> <%= render :partial

    => 'thumbnails' %> <% end %> </div> Original ERB Pseudo ERB / XML <div id="thumbnails" data-hook> <code erb-silent> if @product.present? </code> <code erb-loud> render :partial => 'thumbnails' </code> <code erb-silent> end </code> </div> 1 2 3 4 5 1 2 3 4 5
  22. <div id="thumbnails" data-hook> <% if @product.present? %> <%= render :partial

    => 'thumbnails' %> <% end %> </div> Original ERB Pseudo ERB / XML <div id="thumbnails" data-hook> <code erb-silent> if @product.present? </code> <code erb-loud> render :partial => 'thumbnails' </code> <code erb-silent> end </code> </div> 1 2 3 4 5 1 2 3 4 5
  23. <div id="thumbnails" data-hook> <% if @product.present? %> <%= render :partial

    => 'thumbnails' %> <% end %> </div> Original ERB Pseudo ERB / XML <div id="thumbnails" data-hook> <code erb-silent> if @product.present? </code> <code erb-loud> render :partial => 'thumbnails' </code> <code erb-silent> end </code> </div> 1 2 3 4 5 1 2 3 4 5
  24. <div id="thumbnails" data-hook> <% if @product.present? %> <%= render :partial

    => 'thumbnails' %> <% end %> </div> Original ERB Pseudo ERB / XML <div id="thumbnails" data-hook> <code erb-silent> if @product.present? </code> <code erb-loud> render :partial => 'thumbnails' </code> <code erb-silent> end </code> </div> 1 2 3 4 5 1 2 3 4 5
  25. <h1 data-erb-id="&lt;%= dom_id(@product) %&gt;"> Product Name </h1> Original ERB Pseudo

    ERB / XML <h1 id="<%= dom_id(@product) %>"> Product Name </h1> 1 2 3 1 2 3
  26. <h1 data-erb-id="&lt;%= dom_id(@product) %&gt;"> Product Name </h1> Original ERB Pseudo

    ERB / XML <h1 id="<%= dom_id(@product) %>"> Product Name </h1> 1 2 3 1 2 3
  27. <h1 data-erb-id="&lt;%= dom_id(@product) %&gt;"> Product Name </h1> Original ERB Pseudo

    ERB / XML <h1 id="<%= dom_id(@product) %>"> Product Name </h1> 1 2 3 1 2 3
  28. <p data-erb-0="&lt;%= render_style %&gt;" data-erb-1="&lt;%= show_attrs %&gt;"> Product description </p>

    Original ERB Pseudo ERB / XML <p <%= render_style %> <%= show_attrs %>> Product description </p> 1 2 3 1 2 3
  29. <p data-erb-0="&lt;%= render_style %&gt;" data-erb-1="&lt;%= show_attrs %&gt;"> Product description </p>

    Original ERB Pseudo ERB / XML <p <%= render_style %> <%= show_attrs %>> Product description </p> 1 2 3 1 2 3
  30. <p data-erb-0="&lt;%= render_style %&gt;" data-erb-1="&lt;%= show_attrs %&gt;"> Product description </p>

    Original ERB Pseudo ERB / XML <p <%= render_style %> <%= show_attrs %>> Product description </p> 1 2 3 1 2 3
  31. Rails Deface Original ERB Deface Pre-parser Pseudo ERB XML Nokogiri

    Deface Overrides Deface Post- parser Final ERB
  32. 1 2 3 4 app/overrides/tweak_thumbs.rb 1 2 3 4 5

    6 7 8 app/views/spree/products/show.html.erb <div id="product-images" data-hook="product_images"> <div id="main-image" data-hook> <%= render 'image' %> </div> <div id="thumbnails" data-hook> <%= render 'thumbnails', :product => @product %> </div> </div>
  33. 1 2 3 4 app/overrides/tweak_thumbs.rb 1 2 3 4 5

    6 7 8 app/views/spree/products/show.html.erb <div id="product-images" data-hook="product_images"> <div id="main-image" data-hook> <%= render 'image' %> </div> <div id="thumbnails" data-hook> <%= render 'thumbnails', :product => @product %> </div> </div> Deface::Override.new(:virtual_path => "spree/products/show",
  34. 1 2 3 4 app/overrides/tweak_thumbs.rb 1 2 3 4 5

    6 7 8 app/views/spree/products/show.html.erb <div id="product-images" data-hook="product_images"> <div id="main-image" data-hook> <%= render 'image' %> </div> <div id="thumbnails" data-hook> <%= render 'thumbnails', :product => @product %> </div> </div> Deface::Override.new(:virtual_path => "spree/products/show", :name => "tweak_thumbs",
  35. 1 2 3 4 app/overrides/tweak_thumbs.rb 1 2 3 4 5

    6 7 8 app/views/spree/products/show.html.erb <div id="product-images" data-hook="product_images"> <div id="main-image" data-hook> <%= render 'image' %> </div> <div id="thumbnails" data-hook> <%= render 'thumbnails', :product => @product %> </div> </div> Deface::Override.new(:virtual_path => "spree/products/show", :name => "tweak_thumbs", :insert_bottom => "div#thumbnails",
  36. 1 2 3 4 app/overrides/tweak_thumbs.rb 1 2 3 4 5

    6 7 8 app/views/spree/products/show.html.erb <div id="product-images" data-hook="product_images"> <div id="main-image" data-hook> <%= render 'image' %> </div> <div id="thumbnails" data-hook> <%= render 'thumbnails', :product => @product %> </div> </div> Deface::Override.new(:virtual_path => "spree/products/show", :name => "tweak_thumbs", :insert_bottom => "div#thumbnails", :erb => %q{<span>Hello World</span>})
  37. 1 2 3 4 app/overrides/tweak_thumbs.rb 1 2 3 4 5

    6 7 8 app/views/spree/products/show.html.erb <div id="product-images" data-hook="product_images"> <div id="main-image" data-hook> <%= render 'image' %> </div> <div id="thumbnails" data-hook> <%= render 'thumbnails', :product => @product %> </div> </div> Deface::Override.new(:virtual_path => "spree/products/show", :name => "tweak_thumbs", :insert_bottom => "div#thumbnails", :erb => %q{<span>Hello World</span>})
  38. 1 2 3 4 app/overrides/tweak_thumbs.rb 1 2 3 4 5

    6 7 8 9 app/views/spree/products/show.html.erb <div id="product-images" data-hook="product_images"> <div id="main-image" data-hook> <%= render 'image' %> </div> <div id="thumbnails" data-hook> <%= render 'thumbnails', :product => @product %> </div> </div> Deface::Override.new(:virtual_path => "spree/products/show", :name => "tweak_thumbs", :insert_bottom => "div#thumbnails", :erb => %q{<span>Hello World</span>})
  39. 1 2 3 4 app/overrides/tweak_thumbs.rb 1 2 3 4 5

    6 7 8 9 app/views/spree/products/show.html.erb <div id="product-images" data-hook="product_images"> <div id="main-image" data-hook> <%= render 'image' %> </div> <div id="thumbnails" data-hook> <%= render 'thumbnails', :product => @product %> </div> </div> Deface::Override.new(:virtual_path => "spree/products/show", :name => "tweak_thumbs", :insert_bottom => "div#thumbnails", :erb => %q{<span>Hello World</span>}) <span>Hello World</span>
  40. 1 2 3 4 app/overrides/tweak_thumbs.rb 1 2 3 4 5

    6 7 8 9 app/views/spree/products/show.html.erb <div id="product-images" data-hook="product_images"> <div id="main-image" data-hook> <%= render 'image' %> </div> <div id="thumbnails" data-hook> <span>Hello World</span> <%= render 'thumbnails', :product => @product %> </div> </div> Deface::Override.new(:virtual_path => "spree/products/show", :name => "tweak_thumbs", :insert_top => "div#thumbnails", :erb => %q{<span>Hello World</span>})
  41. 1 2 3 4 app/overrides/tweak_thumbs.rb 1 2 3 4 5

    6 7 8 9 app/views/spree/products/show.html.erb <div id="product-images" data-hook="product_images"> <div id="main-image" data-hook> <%= render 'image' %> </div> <span>Hello World</span> <div id="thumbnails" data-hook> <%= render 'thumbnails', :product => @product %> </div> </div> Deface::Override.new(:virtual_path => "spree/products/show", :name => "tweak_thumbs", :insert_before => "div#thumbnails", :erb => %q{<span>Hello World</span>})
  42. 1 2 3 4 app/overrides/tweak_thumbs.rb 1 2 3 4 5

    6 7 8 9 app/views/spree/products/show.html.erb <div id="product-images" data-hook="product_images"> <div id="main-image" data-hook> <%= render 'image' %> </div> <div id="thumbnails" data-hook> <%= render 'thumbnails', :product => @product %> </div> <span>Hello World</span> </div> Deface::Override.new(:virtual_path => "spree/products/show", :name => "tweak_thumbs", :insert_after => "div#thumbnails", :erb => %q{<span>Hello World</span>})
  43. 1 2 3 4 app/overrides/tweak_thumbs.rb 1 2 3 4 5

    6 app/views/spree/products/show.html.erb <div id="product-images" data-hook="product_images"> <div id="main-image" data-hook> <%= render 'image' %> </div> <span>Hello World</span> </div> Deface::Override.new(:virtual_path => "spree/products/show", :name => "tweak_thumbs", :replace => "div#thumbnails", :erb => %q{<span>Hello World</span>})
  44. 1 2 3 4 app/overrides/tweak_thumbs.rb 1 2 3 4 5

    6 7 8 app/views/spree/products/show.html.erb <div id="product-images" data-hook="product_images"> <div id="main-image" data-hook> <%= render 'image' %> </div> <div id="thumbnails" data-hook> <span>Hello World</span> </div> </div> Deface::Override.new(:virtual_path => "spree/products/show", :name => "tweak_thumbs", :replace_contents => "div#thumbnails", :erb => %q{<span>Hello World</span>})
  45. 1 2 3 4 app/overrides/tweak_thumbs.rb 1 2 3 4 5

    app/views/spree/products/show.html.erb <div id="product-images" data-hook="product_images"> <div id="main-image" data-hook> <%= render 'image' %> </div> </div> Deface::Override.new(:virtual_path => "spree/products/show", :name => "tweak_thumbs", :remove => "div#thumbnails", :erb => %q{<span>Hello World</span>})
  46. <div id="product-images" data-hook="product_images"> <div id="main-image" data-hook> <%= render 'image' %>

    </div> <div id="thumbnails" data-hook> <%= render 'thumbnails', :product => @product %> </div> </div> 1 2 3 4 5 6 7 app/overrides/tweak_thumbs.rb app/views/spree/products/show.html.erb Deface::Override.new(:virtual_path => "spree/products/show", :name => "tweak_thumbs", :surround => "div#thumbnails", :erb => %q{<span> <h2>Images</h2> <%= render_original %> </span>}) 1 2 3 4 5 6 7 8
  47. <div id="product-images" data-hook="product_images"> <div id="main-image" data-hook> <%= render 'image' %>

    </div> <div id="thumbnails" data-hook> <%= render 'thumbnails', :product => @product %> </div> </div> 1 2 3 4 5 6 7 app/overrides/tweak_thumbs.rb app/views/spree/products/show.html.erb Deface::Override.new(:virtual_path => "spree/products/show", :name => "tweak_thumbs", :surround => "div#thumbnails", :erb => %q{<span> <h2>Images</h2> <%= render_original %> </span>}) 1 2 3 4 5 6 7 8
  48. <div id="product-images" data-hook="product_images"> <div id="main-image" data-hook> <%= render 'image' %>

    </div> <div id="thumbnails" data-hook> <%= render 'thumbnails', :product => @product %> </div> </div> 1 2 3 4 5 6 7 app/overrides/tweak_thumbs.rb app/views/spree/products/show.html.erb Deface::Override.new(:virtual_path => "spree/products/show", :name => "tweak_thumbs", :surround => "div#thumbnails", :erb => %q{<span> <h2>Images</h2> <%= render_original %> </span>}) 1 2 3 4 5 6 7 8
  49. 1 2 3 4 5 6 7 app/overrides/tweak_thumbs.rb 1 2

    3 4 5 6 7 8 9 10 11 app/views/spree/products/show.html.erb <div id="product-images" data-hook="product_images"> <div id="main-image" data-hook> <%= render 'image' %> </div> <span> <h2>Images</h2> <div id="thumbnails" data-hook> <%= render 'thumbnails', :product => @product %> </div> </span> </div> Deface::Override.new(:virtual_path => "spree/products/show", :name => "tweak_thumbs", :surround => "div#thumbnails", :erb => %q{<span> <h2>Images</h2> <%= render_original %> </span>})
  50. 1 2 3 4 5 6 7 app/overrides/tweak_thumbs.rb 1 2

    3 4 5 6 7 8 9 10 11 app/views/spree/products/show.html.erb <div id="product-images" data-hook="product_images"> <div id="main-image" data-hook> <%= render 'image' %> </div> <span> <h2>Images</h2> <div id="thumbnails" data-hook> <%= render 'thumbnails', :product => @product %> </div> </span> </div> Deface::Override.new(:virtual_path => "spree/products/show", :name => "tweak_thumbs", :surround => "div#thumbnails", :erb => %q{<span> <h2>Images</h2> <%= render_original %> </span>})
  51. 1 2 3 4 5 app/overrides/tweak_thumbs.rb app/views/spree/products/show.html.erb <div id="product-images" data-hook="product_images">

    <div id="main-image" data-hook> <%= render 'image' %> </div> <div id="thumbnails" data-hook> <span> <%= render 'thumbnails', :product => @product %> </span> </div> </div> Deface::Override.new(:virtual_path => "spree/products/show", :name => "tweak_thumbs", :surround_contents => "div#thumbnails", :erb => %q{<span><%= render_original %></span>}) 1 2 3 4 5 6 7 8 9 10
  52. 1 2 3 4 5 app/overrides/tweak_thumbs.rb app/views/spree/products/show.html.erb <div id="product-images" data-hook="product_images">

    <div id="main-image" data-hook> <%= render 'image' %> </div> <div id="thumbnails" data-hook> <span> <%= render 'thumbnails', :product => @product %> </span> </div> </div> Deface::Override.new(:virtual_path => "spree/products/show", :name => "tweak_thumbs", :surround_contents => "div#thumbnails", :erb => %q{<span><%= render_original %></span>}) 1 2 3 4 5 6 7 8 9 10
  53. 1 2 3 4 5 app/overrides/tweak_thumbs.rb 1 2 3 4

    5 6 7 8 app/views/spree/products/show.html.erb <div id="product-images" data-hook="product_images"> <div id="main-image" data-hook> <%= render 'image' %> </div> <div alt="blah" id="thumbs" data-hook> <%= render 'thumbnails', :product => @product %> </div> </div> Deface::Override.new(:virtual_path => "spree/products/show", :name => "tweak_thumbs", :set_attributes => "div#thumbnails", :attributes => { :alt => "blah" :id => "thumbs"})
  54. 1 2 3 4 5 app/overrides/tweak_thumbs.rb 1 2 3 4

    5 6 7 8 app/views/spree/products/show.html.erb <div id="product-images" data-hook="product_images"> <div id="main-image" data-hook> <%= render 'image' %> </div> <div alt="blah" id="thumbs" data-hook> <%= render 'thumbnails', :product => @product %> </div> </div> Deface::Override.new(:virtual_path => "spree/products/show", :name => "tweak_thumbs", :set_attributes => "div#thumbnails", :attributes => { :alt => "blah" :id => "thumbs"})
  55. 1 2 3 4 5 app/overrides/tweak_thumbs.rb 1 2 3 4

    5 6 7 8 app/views/spree/products/show.html.erb <div id="product-images" data-hook="product_images"> <div id="main-image" data-hook> <%= render 'image' %> </div> <div alt="blah" id="thumbs" data-hook> <%= render 'thumbnails', :product => @product %> </div> </div> Deface::Override.new(:virtual_path => "spree/products/show", :name => "tweak_thumbs", :set_attributes => "div#thumbnails", :attributes => { :alt => "blah" :id => "thumbs"})
  56. 1 2 3 4 app/overrides/tweak_thumbs.rb 1 2 3 4 5

    6 app/views/spree/products/show.html.erb <div id="product-images" data-hook="product_images"> <div id="main-image" data-hook> <%= render 'image' %> </div> <span>Hello World</span> </div> Deface::Override.new(:virtual_path => "spree/products/show", :name => "tweak_thumbs", :replace => "div#thumbnails", :erb => %q{<span>Hello World</span>})
  57. 1 2 3 4 app/overrides/tweak_thumbs.rb 1 2 3 4 5

    6 app/views/spree/products/show.html.erb <div id="product-images" data-hook="product_images"> <div id="main-image" data-hook> <%= render 'image' %> </div> <span><b>Goodbye World</b></span> </div> Deface::Override.new(:virtual_path => "spree/products/show", :name => "tweak_thumbs", :replace => "div#thumbnails", :erb => %q{<span>Hello World</span>}) 1 2 3 4 5 app/overrides/cry_for_help.rb Deface::Override.new(:virtual_path => "spree/products/show", :name => "cry_for_help", :replace_contents => "#product-images span", :erb => “<b>Goodbye World</b>”, :sequence => {:after => ‘tweak_thumbs’})
  58. 1 2 3 4 5 app/overrides/tweak_thumbs.rb 1 2 3 4

    5 6 7 8 app/views/spree/products/show.html.erb <div id="product-images" data-hook="product_images"> <div id="main-image" data-hook> <%= render 'image' %> </div> <div id="thumbnails" data-hook> <%= render 'thumbnails', :product => @product %> </div> </div> Deface::Override.new(:virtual_path => "spree/products/show", :name => "tweak_thumbs", :replace => "div#main-image", :closing_selector => "div#thumbnails", :erb => %q{<span>Hello World</span>})
  59. 1 2 3 4 5 app/overrides/tweak_thumbs.rb 1 2 3 4

    5 6 7 8 app/views/spree/products/show.html.erb <div id="product-images" data-hook="product_images"> <div id="main-image" data-hook> <%= render 'image' %> </div> <div id="thumbnails" data-hook> <%= render 'thumbnails', :product => @product %> </div> </div> Deface::Override.new(:virtual_path => "spree/products/show", :name => "tweak_thumbs", :replace => "div#main-image", :closing_selector => "div#thumbnails", :erb => %q{<span>Hello World</span>})
  60. 1 2 3 4 5 app/overrides/tweak_thumbs.rb 1 2 3 4

    5 6 7 8 app/views/spree/products/show.html.erb <div id="product-images" data-hook="product_images"> <div id="main-image" data-hook> <%= render 'image' %> </div> <div id="thumbnails" data-hook> <%= render 'thumbnails', :product => @product %> </div> </div> Deface::Override.new(:virtual_path => "spree/products/show", :name => "tweak_thumbs", :replace => "div#main-image", :closing_selector => "div#thumbnails", :erb => %q{<span>Hello World</span>})
  61. 1 2 3 4 5 app/overrides/tweak_thumbs.rb 1 2 3 app/views/spree/products/show.html.erb

    Deface::Override.new(:virtual_path => "spree/products/show", :name => "tweak_thumbs", :replace => "div#main-image", :closing_selector => "div#thumbnails", :erb => %q{<span>Hello World</span>}) <div id="product-images" data-hook="product_images"> <span>Hello World</span> </div>
  62. 1 2 3 4 5 6 7 views/spree/products/index.html.erb (pseudo) 1

    2 3 4 5 6 7 views/spree/products/index.html.erb <% content_for :sidebar do %> <div data-hook="homepage_sidebar_navigation"> <% if "products" == @current_controller %> <%= render :partial => 'spree/shared/taxonomies' %> <% end %> </div> <% end %> <code erb-silent> content_for :sidebar do </code> <div data-hook="homepage_sidebar_navigation"> <code erb-silent> if “products” == @current_controller </code> <code erb-loud> render :partial => 'spree/shared/filters' </code> <code erb-silent> end </code> </div> <code erb-silent> end </code>
  63. 1 2 3 4 5 6 7 views/spree/products/index.html.erb (pseudo) 1

    2 3 4 5 6 7 views/spree/products/index.html.erb <% content_for :sidebar do %> <div data-hook="homepage_sidebar_navigation"> <% if "products" == @current_controller %> <%= render :partial => 'spree/shared/taxonomies' %> <% end %> </div> <% end %> <code erb-silent> content_for :sidebar do </code> <div data-hook="homepage_sidebar_navigation"> <code erb-silent> if “products” == @current_controller </code> <code erb-loud> render :partial => 'spree/shared/filters' </code> <code erb-silent> end </code> </div> <code erb-silent> end </code>
  64. 1 2 3 4 5 6 7 app/overrides/tweak_thumbs.rb 1 2

    3 4 5 6 7 views/spree/products/index.html.erb (pseudo) <code erb-silent> content_for :sidebar do </code> <div data-hook="homepage_sidebar_navigation"> <code erb-silent> if “products” == @current_controller </code> <code erb-loud> render :partial =&gt; 'spree/shared/filters' </code> <code erb-silent> end </code> </div> <code erb-silent> end </code> Deface::Override.new(:virtual_path => "products/show", :name => "tweak_thumbs", :replace => %q{code[erb-silent]:contains(‘if “products” == @current_controller’)}, :closing_selector => %q{code[erb-silent]:contains(‘end’)}, :erb => %q{<span>Hello World</span>})
  65. 1 2 3 4 5 6 7 app/overrides/tweak_thumbs.rb 1 2

    3 4 5 6 7 views/spree/products/index.html.erb (pseudo) <code erb-silent> content_for :sidebar do </code> <div data-hook="homepage_sidebar_navigation"> <code erb-silent> if “products” == @current_controller </code> <code erb-loud> render :partial =&gt; 'spree/shared/filters' </code> <code erb-silent> end </code> </div> <code erb-silent> end </code> Deface::Override.new(:virtual_path => "products/show", :name => "tweak_thumbs", :replace => %q{code[erb-silent]:contains(‘if “products” == @current_controller’)}, :closing_selector => %q{code[erb-silent]:contains(‘end’)}, :erb => %q{<span>Hello World</span>})
  66. 1 2 3 4 5 6 7 app/overrides/tweak_thumbs.rb 1 2

    3 4 5 6 7 views/spree/products/index.html.erb (pseudo) <code erb-silent> content_for :sidebar do </code> <div data-hook="homepage_sidebar_navigation"> <code erb-silent> if “products” == @current_controller </code> <code erb-loud> render :partial =&gt; 'spree/shared/filters' </code> <code erb-silent> end </code> </div> <code erb-silent> end </code> Deface::Override.new(:virtual_path => "products/show", :name => "tweak_thumbs", :replace => %q{code[erb-silent]:contains(‘if “products” == @current_controller’)}, :closing_selector => %q{code[erb-silent]:contains(‘end’)}, :erb => %q{<span>Hello World</span>})
  67. 1 2 3 4 5 6 7 app/overrides/tweak_thumbs.rb 1 2

    3 4 5 6 7 views/spree/products/index.html.erb (pseudo) <code erb-silent> content_for :sidebar do </code> <div data-hook="homepage_sidebar_navigation"> <code erb-silent> if “products” == @current_controller </code> <code erb-loud> render :partial =&gt; 'spree/shared/filters' </code> <code erb-silent> end </code> </div> <code erb-silent> end </code> Deface::Override.new(:virtual_path => "products/show", :name => "tweak_thumbs", :replace => %q{code[erb-silent]:contains(‘if “products” == @current_controller’)}, :closing_selector => %q{code[erb-silent]:contains(‘end’)}, :erb => %q{<span>Hello World</span>})
  68. 1 2 3 4 5 6 7 app/overrides/tweak_thumbs.rb 1 2

    3 4 5 6 7 views/spree/products/index.html.erb (pseudo) <code erb-silent> content_for :sidebar do </code> <div data-hook="homepage_sidebar_navigation"> <code erb-silent> if “products” == @current_controller </code> <code erb-loud> render :partial =&gt; 'spree/shared/filters' </code> <code erb-silent> end </code> </div> <code erb-silent> end </code> Deface::Override.new(:virtual_path => "products/show", :name => "tweak_thumbs", :replace => %q{code[erb-silent]:contains(‘if “products” == @current_controller’)}, :closing_selector => %q{code[erb-silent]:contains(‘end’)}, :erb => %q{<span>Hello World</span>})
  69. 1 2 3 4 5 6 7 app/overrides/tweak_thumbs.rb 1 2

    3 views/spree/products/index.html.erb (pseudo) <code erb-silent> content_for :sidebar do </code> <span>Hello World</span> <code erb-silent> end </code> Deface::Override.new(:virtual_path => "products/show", :name => "tweak_thumbs", :replace => %q{code[erb-silent]:contains(‘if “products” == @current_controller’)}, :closing_selector => %q{code[erb-silent]:contains(‘end’)}, :erb => %q{<span>Hello World</span>})
  70. ~

  71. 1 2 3 4 5 app/overrides/tweak_thumbs.rb 1 2 3 4

    5 6 app/views/spree/products/show.html.erb <div id="product-images" data-hook="product_images"> <div id="main-image" data-hook> <%= render 'image' %> </div> <span>Hello World</span> </div> Deface::Override.new(:virtual_path => "spree/products/show", :name => "tweak_thumbs", :replace => "div#thumbnails", :erb => %q{<span>Hello World</span>}, :original => %q{<%= render 'thumbnails', :product => @product %>})
  72. 1 2 3 4 5 app/overrides/tweak_thumbs.rb 1 2 3 4

    5 6 app/views/spree/products/show.html.erb <div id="product-images" data-hook="product_images"> <div id="main-image" data-hook> <%= render 'image' %> </div> <span>Hello World</span> </div> Deface::Override.new(:virtual_path => "spree/products/show", :name => "tweak_thumbs", :replace => "div#thumbnails", :erb => %q{<span>Hello World</span>}, :original => %q{<%= render 'thumbnails', :product => @product %>}) $ Deface [WARNING]: The original source for 'tweak_thumbs' has changed, this override should be reviewed to ensure it's still valid.
  73. 1 2 3 4 app/overrides/tweak_thumbs.rb 1 2 3 4 5

    6 app/views/spree/products/show.html.erb <div id="product-images" data-hook="product_images"> <div id="main-image" data-hook> <%= render 'image' %> </div> <span>Hello World</span> </div> Deface::Override.new(:virtual_path => "spree/products/show", :name => "tweak_thumbs", :replace => "div#thumbnails", :erb => %q{<span>Hello World</span>})
  74. $ Deface [WARNING]: No :original defined for 'tweak_thumbs', you should

    change its definition to include: :original => 'eb3fa668cd98b6a1c75c36420ef1b238a1fc55ac'. 1 2 3 4 app/overrides/tweak_thumbs.rb 1 2 3 4 5 6 app/views/spree/products/show.html.erb <div id="product-images" data-hook="product_images"> <div id="main-image" data-hook> <%= render 'image' %> </div> <span>Hello World</span> </div> Deface::Override.new(:virtual_path => "spree/products/show", :name => "tweak_thumbs", :replace => "div#thumbnails", :erb => %q{<span>Hello World</span>})
  75. 1 2 3 4 app/overrides/tweak_thumbs.rb 1 2 3 4 5

    6 app/views/spree/products/show.html.erb <div id="product-images" data-hook="product_images"> <div id="main-image" data-hook> <%= render 'image' %> </div> <span>Hello World</span> </div> Deface::Override.new(:virtual_path => "spree/products/show", :name => "tweak_thumbs", :replace => "div#thumbnails", :erb => %q{<span>Hello World</span>}, :original => "eb3fa668cd98b6a1c75c36420ef1b238a1fc55ac")
  76. 1 2 3 4 5 6 7 8 app/views/spree/products/show.html.erb <div

    id="product-images" data-hook="product_images"> <div id="main-image" data-hook> <%= render 'image' %> </div> <div id="thumbnails" data-hook> <%= render 'thumbnails', :product => @product %> </div> </div>
  77. 1 2 3 4 5 6 7 8 app/views/spree/products/show.html.erb <div

    id="product-images" data-hook="product_images"> <div id="main-image" data-hook> <%= render 'image' %> </div> <div id="thumbnails" data-hook> <%= render 'thumbnails', :product => @product %> </div> </div> [data-hook=‘product_images’]
  78. 1 2 3 4 5 6 7 8 app/views/spree/products/show.html.erb <div

    id="product-images" data-hook="product_images"> <div id="main-image" data-hook> <%= render 'image' %> </div> <div id="thumbnails" data-hook> <%= render 'thumbnails', :product => @product %> </div> </div> [data-hook=‘product_images’] #thumbnails[data-hook]
  79. Rails Deface Deface Pre-parser Pseudo ERB XML Nokogiri Deface Overrides

    Deface Post- parser Final ERB Original Haml Deface Haml Converter Converted ERB
  80. Rails Deface Deface Pre-parser Pseudo ERB XML Nokogiri Deface Overrides

    Deface Post- parser Final ERB Original Haml Deface Haml Converter Converted ERB
  81. 1 2 3 app/views/spree/shared/_nav_bar.html.erb <li id="search-bar" data-hook> <%= render :partial

    => 'spree/shared/search' %> </li> <li id="search-bar" data-hook> <code erb-loud> render :partial => 'spree/shared/search' </code> </li> Pseudo ERB / XML 1 2 3
  82. 1 2 3 4 app/overrides/tweak_thumbs.rb 1 2 3 app/views/spree/shared/_nav_bar.html.erb Deface::Override.new(:name

    => 'insert_blog_link_in_nav_bar', :virtual_path => 'spree/shared/_nav_bar', :insert_after => '#search-bar[data-hook]', :haml => %q{%li{:id => 'blog'}= link_to 'Blog', blog_path}) <li id="search-bar" data-hook> <%= render :partial => 'spree/shared/search' %> </li> <li id="search-bar" data-hook> <code erb-loud> render :partial => 'spree/shared/search' </code> </li> Pseudo ERB / XML 1 2 3
  83. 1 2 3 4 app/overrides/tweak_thumbs.rb 1 2 3 app/views/spree/shared/_nav_bar.html.erb Deface::Override.new(:name

    => 'insert_blog_link_in_nav_bar', :virtual_path => 'spree/shared/_nav_bar', :insert_after => '#search-bar[data-hook]', :haml => %q{%li{:id => 'blog'}= link_to 'Blog', blog_path}) <li id="search-bar" data-hook> <%= render :partial => 'spree/shared/search' %> </li> <li id="search-bar" data-hook> <code erb-loud> render :partial => 'spree/shared/search' </code> </li> Pseudo ERB / XML 1 2 3
  84. 1 2 app/views/spree/shared/_nav_bar.html.haml %li#search-bar{"data-hook" => ""} = render :partial =>

    'spree/shared/search' 1 2 3 4 app/overrides/tweak_thumbs.rb Deface::Override.new(:name => 'insert_blog_link_in_nav_bar', :virtual_path => 'spree/shared/_nav_bar', :insert_after => '#search-bar[data-hook]', :haml => %q{%li{:id => 'blog'}= link_to 'Blog', blog_path}) <li id="search-bar" data-hook> <code erb-loud> render :partial => 'spree/shared/search' </code> </li> Pseudo ERB / XML 1 2 3
  85. 1 2 app/views/spree/shared/_nav_bar.html.haml %li#search-bar{"data-hook" => ""} = render :partial =>

    'spree/shared/search' 1 2 3 4 app/overrides/tweak_thumbs.rb Deface::Override.new(:name => 'insert_blog_link_in_nav_bar', :virtual_path => 'spree/shared/_nav_bar', :insert_after => '#search-bar[data-hook]', :haml => %q{%li{:id => 'blog'}= link_to 'Blog', blog_path}) <li id="search-bar" data-hook> <code erb-loud> render :partial => 'spree/shared/search' </code> </li> Pseudo ERB / XML 1 2 3
  86. Deface::Override.new(:virtual_path => "spree/shared/_store_menu", :name => "remove_home_link", :remove => "#home-link[data-hook]") app/overrides/remove_home_link.rb

    app/spree/shared/_store_menu.html.erb <li id="home-link" data-hook><%= link_to t(:home), root_path %></li> <li id="link-to-cart" data-hook><%= link_to_cart %></li>
  87. Deface::Override.new(:virtual_path => "spree/shared/_store_menu", :name => "remove_home_link", :remove => "#home-link[data-hook]") app/overrides/remove_home_link.rb

    app/spree/shared/_store_menu.html.erb <li id="home-link" data-hook><%= link_to t(:home), root_path %></li> <li id="link-to-cart" data-hook><%= link_to_cart %></li> app/compiled_views/_store_menu.html.erb <li id="link-to-cart" data-hook><%= link_to_cart %></li>
  88. 1 2 3 4 spree_social/app/overrides/add_icons.rb Deface::Override.new(:virtual_path => "spree/users/new", :name =>

    "add_icons", :replace => "[data-hook=‘user_form’]", :erb => %q{<img src=”icons.png”>}) 1 2 3 app/overrides/tweak_social_icons.rb Deface::Override.new(:virtual_path => "spree/users/new", :name => "add_icons", :erb => %q{<img src=”my-icons.png”>})
  89. Started GET "/" for 127.0.0.1 at Mon Jan 16 12:01:29

    +0000 2012 Processing by Spree::HomeController#index as */* Rendered /spree/core/app/views/spree/shared/_taxonomies.html.erb (9.0ms) Rendered /spree/core/app/views/spree/shared/_products.html.erb (26.7ms) Rendered /spree/core/app/views/spree/home/index.html.erb within /spree/layouts/spree_application (36.6ms) Rendered /spree/core/app/views/spree/shared/_head.html.erb (1.6ms) Rendered /spree/core/app/views/spree/shared/_search.html.erb (2.1ms) Rendered /spree/core/app/views/spree/shared/_store_menu.html.erb (0.7ms) Rendered /spree/core/app/views/spree/shared/_nav_bar.html.erb (3.9ms) Rendered /spree/core/app/views/spree/shared/_google_analytics.html.erb (0.8ms) Completed 200 OK in 48ms (Views: 43.2ms | ActiveRecord: 2.2ms)
  90. Started GET "/" for 127.0.0.1 at Mon Jan 16 12:01:29

    +0000 2012 Processing by Spree::HomeController#index as */* Rendered /spree/core/app/views/spree/shared/_taxonomies.html.erb (9.0ms) Rendered /spree/core/app/views/spree/shared/_products.html.erb (26.7ms) Rendered /spree/core/app/views/spree/home/index.html.erb within /spree/layouts/spree_application (36.6ms) Rendered /spree/core/app/views/spree/shared/_head.html.erb (1.6ms) Rendered /spree/core/app/views/spree/shared/_search.html.erb (2.1ms) Rendered /spree/core/app/views/spree/shared/_store_menu.html.erb (0.7ms) Rendered /spree/core/app/views/spree/shared/_nav_bar.html.erb (3.9ms) Rendered /spree/core/app/views/spree/shared/_google_analytics.html.erb (0.8ms) Completed 200 OK in 48ms (Views: 43.2ms | ActiveRecord: 2.2ms) Started GET "/" for 127.0.0.1 at Mon Jan 16 11:51:29 +0000 2012 Processing by Spree::HomeController#index as */* Rendered /spree/core/app/views/spree/home/index.html.erb within /spree/layouts/spree_application (27.5ms) Completed 200 OK in 36ms (Views: 31.8ms | ActiveRecord: 1.8ms)
  91. 1 2 3 4 app/overrides/render_no_more.rb 1 2 3 views/spree/layouts/spree_application.html.erb <head

    data-hook="inside_head"> <%= render :partial => 'spree/shared/head' %> </head> Deface::Override.new(:virtual_path => 'spree/layouts/spree_application', :name => 'render_no_more', :replace => "code:contains('spree/shared/head')", :partial => 'spree/shared/head') https://gist.github.com/1345a8603b4c90e26540
  92. No Renders With Renders Avg (ms) 77.62 92.61 Max (ms)

    313.7 435.4 Min (ms) 28.9 31.3 Total (mins) 12.94 15.44
  93. ---------------- Before ---------------- <li id="home-link" data-hook><%= link_to t(:home), root_path %></li>

    <li id="link-to-cart" data-hook><%= link_to_cart %></li> ---------------- Overrides (1)-------- - 'remove_home_link' will be applied. ---------------- After ---------------- <li id="link-to-cart" data-hook><%= link_to_cart %></li> ---------------- Diff ----------------- -<li id="home-link" data-hook><%= link_to t(:home), root_path %></li> <li id="link-to-cart" data-hook><%= link_to_cart %></li>
  94. $ rake deface:test_selector[ spree/shared/_store_menu, ‘li’] Querying 'spree/shared/_store_menu' for 'li' ----------------

    Match 1 ---------------- <li id="home-link" data-hook><%= link_to t(:home), root_path %></li> ---------------- Match 2 ---------------- <li id="link-to-cart" data-hook><%= link_to_cart %></li>
  95. 1 2 3 4 app/overrides/never_gonna.rb Deface::Override.new(:virtual_path => "products/show", :name =>

    "never_gonna", :set_attributes => "a", :attributes => {:href => "http://youtu.be/dQw4w9WgXcQ"})
  96. 1 2 3 4 app/overrides/never_gonna.rb Deface::Override.new(:virtual_path => "products/show", :name =>

    "never_gonna", :set_attributes => "a", :attributes => {:href => "http://youtu.be/dQw4w9WgXcQ"})
  97. 1 2 3 4 app/overrides/tweak_thumbs.rb 1 2 3 4 5

    6 7 8 app/views/spree/products/show.html.erb <div id="product-images" data-hook="product_images"> <div id="main-image" data-hook> <%= render 'image' %> </div> <div id="thumbnails" data-hook> <%= render 'thumbnails', :product => @product %> </div> </div> Deface::Override.new(:virtual_path => "spree/products/show", :name => "tweak_thumbs", :cut => "div#main-image", :insert_bottom => "div#thumbnails")
  98. 1 2 3 4 app/overrides/tweak_thumbs.rb 1 2 3 4 5

    6 7 8 app/views/spree/products/show.html.erb <div id="product-images" data-hook="product_images"> <div id="main-image" data-hook> <%= render 'image' %> </div> <div id="thumbnails" data-hook> <%= render 'thumbnails', :product => @product %> </div> </div> Deface::Override.new(:virtual_path => "spree/products/show", :name => "tweak_thumbs", :cut => "div#main-image", :insert_bottom => "div#thumbnails")
  99. 1 2 3 4 app/overrides/tweak_thumbs.rb 1 2 3 4 5

    6 7 8 app/views/spree/products/show.html.erb <div id="product-images" data-hook="product_images"> <div id="thumbnails" data-hook> <%= render 'thumbnails', :product => @product %> <div id="main-image" data-hook> <%= render 'image' %> </div> </div> </div> Deface::Override.new(:virtual_path => "spree/products/show", :name => "tweak_thumbs", :cut => "div#main-image", :insert_bottom => "div#thumbnails")
  100. 1 2 3 4 app/overrides/tweak_thumbs.rb 1 2 3 4 5

    6 7 8 app/views/spree/products/show.html.erb <div id="product-images" data-hook="product_images"> <div id="main-image" data-hook> <%= render 'image' %> </div> <div id="thumbnails" data-hook> <%= render 'thumbnails', :product => @product %> </div> </div> Deface::Override.new(:virtual_path => "spree/products/show", :name => "tweak_thumbs", :copy => "div#main-image", :insert_bottom => "div#thumbnails")
  101. 1 2 3 4 app/overrides/tweak_thumbs.rb 1 2 3 4 5

    6 7 8 app/views/spree/products/show.html.erb <div id="product-images" data-hook="product_images"> <div id="main-image" data-hook> <%= render 'image' %> </div> <div id="thumbnails" data-hook> <%= render 'thumbnails', :product => @product %> </div> </div> Deface::Override.new(:virtual_path => "spree/products/show", :name => "tweak_thumbs", :copy => "div#main-image", :insert_bottom => "div#thumbnails")
  102. 1 2 3 4 app/overrides/tweak_thumbs.rb 1 2 3 4 5

    6 7 8 9 10 11 app/views/spree/products/show.html.erb Deface::Override.new(:virtual_path => "spree/products/show", :name => "tweak_thumbs", :cut => "div#main-image", :insert_bottom => "div#thumbnails") <div id="product-images" data-hook="product_images"> <div id="main-image" data-hook> <%= render 'image' %> </div> <div id="thumbnails" data-hook> <%= render 'thumbnails', :product => @product %> <div id="main-image" data-hook> <%= render 'image' %> </div> </div> </div>