开发者

Rails 3: How do you style will_paginate links?

开发者 https://www.devze.com 2023-04-05 15:22 出处:网络
In coding layout is the link styled like <a href=\"#\" class=\"class1 class2 class3\"><span>Previous</span></a>

In coding layout is the link styled like

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

I tried to search and I found some possible modifications of a shape of these two links. It's:

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

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

My question: How can I update the second example to the shape of the开发者_运维问答 first example? My problem is those two span elements...

Thanks


It's can be very easy - just add html markup for your paginate components to your config/locales/en.yml file for example:

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

It's all!


http://thewebfellas.com/blog/2010/8/22/revisited-roll-your-own-pagination-links-with-will_paginate-and-rails-3 You can have your own formatter so you can customize anything you want.


Wiki

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号