Share
Embed
SpreeConf 2012: Spree themes with Deface
Overview of Spree's new core theme, and a deep dive into Deface.
Brian Quinn
February 19, 2012
Transcript
234 slides
-
spree/spree_reviews • Fork it • sign in to Travis-CI •
Test Hook @joshkalderimis -
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! -
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! -
Versionfile "1.0.x" => { :branch => "master" } "0.70.x" =>
{ :ref => "4aedfg" } -
1 2 3 4 5 6 7 8 9 10
11 12 13 14 15 16 -
<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 -
<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 -
<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 -
/* 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 -
/* 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 -
/* 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 -
/* 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 -
/* 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 -
/* 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 -
Deface::Override.new(:virtual_path => "spree/products/show", :name => "tweak_thumbs", :replace => "div#thumbnails", :erb
=> %q{<span>Hello World</span>}) app/overrides/tweak_thumbs.rb -
Deface::Override.new(:virtual_path => "spree/products/show", :name => "tweak_thumbs", :replace => "div#thumbnails", :erb
=> %q{<span>Hello World</span>}) app/overrides/tweak_thumbs.rb -
Deface::Override.new(:virtual_path => "spree/products/show", :name => "tweak_thumbs", :replace => "div#thumbnails", :erb
=> %q{<span>Hello World</span>}) app/overrides/tweak_thumbs.rb -
:remove :replace :replace_contents :surround :surround_contents :insert_after :insert_before :insert_top :insert_bottom :set_attributes
Actions :action => “css selector” -
<div id="thumbnails" data-hook> <% if @product.present? %> <%= render :partial
=> 'thumbnails' %> <% end %> </div> Original ERB 1 2 3 4 5 -
<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 -
<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 -
<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 -
<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 -
<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 -
<h1 data-erb-id="<%= dom_id(@product) %>"> Product Name </h1> Original ERB Pseudo
ERB / XML <h1 id="<%= dom_id(@product) %>"> Product Name </h1> 1 2 3 1 2 3 -
<h1 data-erb-id="<%= dom_id(@product) %>"> Product Name </h1> Original ERB Pseudo
ERB / XML <h1 id="<%= dom_id(@product) %>"> Product Name </h1> 1 2 3 1 2 3 -
<h1 data-erb-id="<%= dom_id(@product) %>"> Product Name </h1> Original ERB Pseudo
ERB / XML <h1 id="<%= dom_id(@product) %>"> Product Name </h1> 1 2 3 1 2 3 -
Original ERB <p <%= render_style %> <%= show_attrs %>> Product
description </p> 1 2 3 -
<p data-erb-0="<%= render_style %>" data-erb-1="<%= show_attrs %>"> Product description </p>
Original ERB Pseudo ERB / XML <p <%= render_style %> <%= show_attrs %>> Product description </p> 1 2 3 1 2 3 -
<p data-erb-0="<%= render_style %>" data-erb-1="<%= show_attrs %>"> Product description </p>
Original ERB Pseudo ERB / XML <p <%= render_style %> <%= show_attrs %>> Product description </p> 1 2 3 1 2 3 -
<p data-erb-0="<%= render_style %>" data-erb-1="<%= show_attrs %>"> Product description </p>
Original ERB Pseudo ERB / XML <p <%= render_style %> <%= show_attrs %>> Product description </p> 1 2 3 1 2 3 -
Rails Deface Original ERB Deface Pre-parser Pseudo ERB XML Nokogiri
Deface Overrides -
Rails Deface Original ERB Deface Pre-parser Pseudo ERB XML Nokogiri
Deface Overrides -
Rails Deface Original ERB Deface Pre-parser Pseudo ERB XML Nokogiri
Deface Overrides Deface Post- parser -
Rails Deface Original ERB Deface Pre-parser Pseudo ERB XML Nokogiri
Deface Overrides Deface Post- parser Final ERB -
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> -
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", -
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", -
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", -
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>}) -
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>}) -
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>}) -
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> -
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>}) -
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>}) -
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>}) -
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>}) -
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>}) -
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>}) -
<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 -
<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 -
<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 -
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>}) -
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>}) -
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 -
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 -
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"}) -
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"}) -
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"}) -
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>}) -
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’}) -
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>}) -
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>}) -
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>}) -
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> -
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> -
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> -
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 => '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>}) -
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 => '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>}) -
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 => '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>}) -
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 => '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>}) -
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 => '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>}) -
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>}) -
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 %>}) -
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. -
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>}) -
$ 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>}) -
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") -
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> -
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’] -
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] -
Rails Deface Deface Pre-parser Pseudo ERB XML Nokogiri Deface Overrides
Deface Post- parser Final ERB Original Haml Deface Haml Converter Converted ERB -
Rails Deface Deface Pre-parser Pseudo ERB XML Nokogiri Deface Overrides
Deface Post- parser Final ERB Original Haml Deface Haml Converter Converted ERB -
1 2 3 app/views/spree/shared/_nav_bar.html.erb <li id="search-bar" data-hook> <%= render :partial
=> 'spree/shared/search' %> </li> -
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 -
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 -
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 -
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 -
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 -
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> -
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> -
[WARNING] Precompiled views present and Deface is enabled, this can
result in overrides being applied twice. -
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”>}) -
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 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) -
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 -
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 -
---------------- 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> -
$ 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> -
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"}) -
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"}) -
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") -
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") -
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") -
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") -
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") -
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>