在单双行显示不同的颜色Rails的一些view helper
发布日期:2021-09-29 20:08:32 浏览次数:3 分类:技术文章

本文共 1543 字,大约阅读时间需要 5 分钟。

cycle总是忘了,搬回来标记一下
# Alternate CSS classes for even and odd numbers...   @items = [1,2,3,4]   
<% @items.each do |item| %>
">
<% end %>
item
# Cycle CSS classes for rows, and text colors for values within each row @items = x = [{:first => 'Robert', :middle => 'Daniel', :last => 'James'}, {:first => 'Emily', :middle => 'Shannon', :maiden => 'Pike', :last => 'Hicks'}, {:first => 'June', :middle => 'Dae', :last => 'Jones'}] <% @items.each do |item| %> "row_class") -%>"> <% item.values.each do |value| %> <%# Create a named cycle "colors" %> "colors") -%>"> <%= value %> <% end %> <% reset_cycle("colors") %> <% end %>
还有两个helper
也可以一起
truncate("Once upon a time in a world far far away")   # => "Once upon a time in a world..."   truncate("Once upon a time in a world far far away", :length => 17)   # => "Once upon a ti..."   truncate("Once upon a time in a world far far away", :length => 17, :separator => ' ')   # => "Once upon a..."   truncate("And they found that many people were sleeping better.", :length => 25, :omission => '... (continued)')   # => "And they f... (continued)"   truncate("

Once upon a time in a world far far away

") # => "

Once upon a time in a wo..."

pluralize(1, 'person')   # => 1 person   pluralize(2, 'person')   # => 2 people   pluralize(3, 'person', 'users')   # => 3 users   pluralize(0, 'person')   # => 0 people

转载地址:https://blog.csdn.net/horace_lee/article/details/83712194 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:Rails selenium测试 定位和一些事件解释
下一篇:Rails 异步发送邮件和测试

发表评论

最新留言

留言是一种美德,欢迎回访!
[***.207.175.100]2024年04月15日 17时15分54秒