1
votes

In "spree_application.html.erb" file I need to override an existing partial Get the complete code from below link :

https://github.com/spree/spree/blob/v2.1.2/frontend/app/views/spree/layouts/spree_application.html.erb

sample contents :

      <%= render :partial => 'spree/shared/header' %>

      <div id="wrapper" class="row" data-hook>

        <%= breadcrumbs(@taxon) %>

        <%= render :partial => 'spree/shared/sidebar' if content_for? :sidebar %>

        <div id="content" class="columns <%= !content_for?(:sidebar) ? "sixteen" : "twelve" %>" data-hook>
          <%= flash_messages %>
          <%= yield %>
        </div>

        <%= yield :templates %>

      </div>

Here I need to replace following partial using Deface:

  <%= render :partial => 'spree/shared/header' %>

my Deface file : header_modification.rb :

 Deface::Override.new(:virtual_path => 'spree/layouts/spree_application',
                      :name         => 'header_modification',
                      :replace      =>    ?
                      :partial      => 'spree/shared/spree_application'
                     )

What should be written in :replace part / any other action can be used to override that partial using Deface ?

2

2 Answers

6
votes

You can test your rake selector using the following command:

rake deface:test_selector['spree/layouts/spree_application','erb[loud]:contains("spree/shared/header")']

Querying 'spree/layouts/spree_application' for 'erb[loud]:contains("spree/shared/header")'
---------------- Match 1 ----------------
<%= render :partial => 'spree/shared/header' %>

So this should work:

Deface::Override.new(:virtual_path => 'spree/layouts/spree_application',
                     :name         => 'header_modification',
                     :replace      => 'erb[loud]:contains("spree/shared/header")',
                     :partial      => 'spree/shared/spree_application'
                    )
0
votes

using <code erb-loud> render :partial => 'spree/shared/header' </code> should be working. There is a useful tool by the way which tells you that: http://deface.heroku.com/