rails常用语法

1.附件列表

      ul.m_item_list
        -@page.attachment_list('手机图片').each do |attachment|
          li
            = link_to '/posts/1', class: 'wrap' do
              = image_tag amalgam.attachment_url(attachment)
              p.des
                = attachment.description
              p.type 干红葡萄酒
              .button
                = image_tag('button_details.jpg')
/=image_tag attachment.file.url
  = properties_for @page do |p|
    # 提供文本框修改 @page 对象的 title
    = p.string 'title'
    # 提供文本框修改 @page 对象的 content['title'] 属性
    = p.string 'content.title'
    # 上传名为 pic 的附件
    = p.attachment 'pic'
    # 上传名为 pics 的附件列表
    = p.attachment_list 'pics'

 

 2.带有index的

-@page.children.each_with_index do |attachment,index|

 3.自身与兄弟元素

-@page.parent.self_and_siblings.each do |sub_nav|

 4.properties button

      ul
        -Page.find_by_slug('tickets-top').children.each do |ticket|
          li
            =link_to(ticket.content['url'] || '#', target: '_blank') do
              =editable_image_tag ticket, 'content.image',:display => '245x162!',:placeholder_options => {:width => 245, :height => 162}
              h3=ticket.title
              h2="¥#{ticket.content['price']}"
              .btn 立即抢购
            = properties_button ticket do |f|
              = f.string 'title'
              = f.string 'content.price'
              = f.string 'content.url'
              = f.string 'content.wap_url'

 5.content_tag

=editable_content_tag :div,@page,'content.content',:class=>'article' do
        |

 6.content_img

=editable_image_tag @page,:display => '80x371!', :placeholder => "position.png",:placeholder_options => {:width => 80, :height => 371}
展位图不在本地时
=editable_image_tag @page,'content.produce_place',:display => '262x202!',:placeholder_options => {:width => 262, :height => 202}

 7.home是举例子 是文件夹

pages
|-- home
    |-- &1.html.slim
    |-- &2.html.slim

页面:

|-- home
      |-- child1            (home/&1.html.slim)
      |-- child2            (home/&1.html.slim)
      |   |-- grand_child   (home/&2.html.slim)

 8变量穿插

 h2="¥#{ticket.content['price']}"

  =image_tag("tag_#{tag}.jpg")

9.日期

= order.created_at.strftime('%Y.%m.%d')

10.

转载于:https://www.cnblogs.com/forgere/p/5689070.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值