我想使用Deface将类从"第四列"替换为"第三列".
<aside id="sidebar" class="columns four" data-hook>
<%= yield :sidebar %>
</aside>
Run Code Online (Sandbox Code Playgroud)
我不确定我需要采取什么行动和来源.这就是我到目前为止所拥有的.
Deface::Override.new(:virtual_path => "shared/_sidebar",
:name => "grid",
:set_attributes => '.columns three',
:attributes => {:class => 'pretty', :title => 'This is a link'})
Run Code Online (Sandbox Code Playgroud)
你几乎在那里:
Deface::Override.new(
:virtual_path => 'spree/shared/_sidebar',
:name => 'grid',
:set_attributes => '.columns.four',
:attributes => {:class => 'columns three', :title => 'This is a link'})
Run Code Online (Sandbox Code Playgroud)
你不需要:source或:action用:set_attributes.请注意,该选项set_attributes用于选择当前存在的内容(即您要更改的内容),并提供带有:attributes选项的新属性.
编辑:污损评论的问题:
Deface::Override.new(
:virtual_path => 'path/to/view',
:name => 'some name',
:replace => %{[erb-loud]:contains(' !content_for?(:sidebar) ? "sixteen" : "twelve" ')},
text: '<%= !content_for?(:sidebar) ? "thirteen" : "twelve" %>"'
)
Run Code Online (Sandbox Code Playgroud)
在较新版本的Deface中,您也应该能够使用erb[loud],只需要进行小的语法更改.
| 归档时间: |
|
| 查看次数: |
1299 次 |
| 最近记录: |