在“spree_application.html.erb”文件中,我需要覆盖现有的部分 从以下链接获取完整代码:
示例内容:
<%= 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>
这里我需要使用Deface替换以下部分:
<%= render :partial => 'spree/shared/header' %>
我的Deface文件:header_modification.rb:
Deface::Override.new(:virtual_path => 'spree/layouts/spree_application',
:name => 'header_modification',
:replace => ?
:partial => 'spree/shared/spree_application'
)
应该写什么:替换部分/任何其他动作可以用来使用Deface覆盖那部分?
答案 0 :(得分:6)
您可以使用以下命令测试您的rake选择器:
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' %>
所以这应该有效:
Deface::Override.new(:virtual_path => 'spree/layouts/spree_application',
:name => 'header_modification',
:replace => 'erb[loud]:contains("spree/shared/header")',
:partial => 'spree/shared/spree_application'
)
答案 1 :(得分:0)
使用<code erb-loud> render :partial => 'spree/shared/header' </code>
应该正常工作。顺便说一下,有一个有用的工具可以告诉你:http://deface.heroku.com/