Rails 3:你如何设计will_paginate链接?

时间:2011-09-16 17:12:32

标签: html css ruby-on-rails-3 view will-paginate

在编码布局中,链接样式为

<a href="#" class="class1 class2 class3"><span>Previous</span></a>
<a href="#" class="class1 class2 class3"><span>Next</span>

我试图搜索,我发现这两个链接的形状有一些可能的修改。它是:

<div class="pag">
  <%= will_paginate @data, :page_links => false, :next_label => '' %> 
</div>

<div class="pag">
  <%= will_paginate @data, :page_links => false, :previous_label => '' %>
</div>

我的问题:如何将第二个示例更新为第一个示例的形状?我的问题是那两个span元素......

由于

3 个答案:

答案 0 :(得分:7)

它可以非常简单 - 只需将paginate组件的html标记添加到config / locales / en.yml文件中 例如:

en:
  hello: "Hello world"
  will_paginate:
    previous_label: <span class="glyph glyph-prev"></span>
    next_label: <span class="glyph glyph-next"></span>

一切都好!

答案 1 :(得分:2)

http://thewebfellas.com/blog/2010/8/22/revisited-roll-your-own-pagination-links-with-will_paginate-and-rails-3您可以拥有自己的格式化程序,以便自定义任何内容。

答案 2 :(得分:0)

<强>维基

en:
  will_paginate:
    previous_label: "&#8592; Previous"
    next_label: "Next &#8594;"
    page_gap: "&hellip;"

https://github.com/mislav/will_paginate/wiki/I18n#translating-will_paginate-output