如何使用deface来更改带有erb标签的html

时间:2015-07-02 13:35:59

标签: ruby-on-rails ruby spree deface

我是狂热的新手,并尝试在结账时通过使用deface删除一些字段来更改地址表单。我现在使用哪个选择器,id值是erb格式。以下是部分

形式的代码示例
    <% address_id = address_type.chars.first %>

    <p class="form-group" id=<%="#{address_id}zipcode" %>>
    <%= form.label :zipcode, Spree.t(:zip) %><% if address.require_zipcode? %><span class="required">*</span><br /><% end %>
    <%= form.text_field :zipcode, :class => "form-control #{'required' if address.require_zipcode?}" %>
  </p>
  <p class="form-group" id=<%="#{address_id}phone" %>>
    <%= form.label :phone, Spree.t(:phone) %><% if address.require_phone? %><span class="required">*</span><br /><% end %>
    <%= form.phone_field :phone, :class => "form-control #{'required' if address.require_phone?}" %>
  </p>
  <% if Spree::Config[:alternative_shipping_phone] %>
    <p class="form-group" id=<%="#{address_id}altphone" %>>
      <%= form.label :alternative_phone, Spree.t(:alternative_phone) %><br />
      <%= form.phone_field :alternative_phone, :class => 'form-control' %>
    </p>

试过这个例子

Deface::Override.new(
    :virtual_path   => "spree/address/_form",
    :name           => "remove_phone",
    :remove         => "data-erb-id=&lt;%= \"address_type.chars.firstphone\" %&gt;",
)

但在运行rake deface:get_result[spree/address/_form]后我收到错误消息: Nokogiri :: CSS :: SyntaxError:'[#]'

之后的意外'='

这是我第一次使用spree,但是spree网站上的文档似乎没有用erb覆盖html标签

1 个答案:

答案 0 :(得分:3)

在破损中试试这个

Deface::Override.new(:virtual_path  => "spree/address/_form",
                     :remove => "p[data-erb-id='<%=\"\#{address_id}phone\" %>']",
                     :name          => "remove_phone")