HAML和Ruby循环以及UL不起作用 [英] HAML and Ruby loop and UL not working

查看:78
本文介绍了HAML和Ruby循环以及UL不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使这个简单的列表生效,但是ul正在关闭,并且没有将li元素包含在循环中.我是否缺少执行此操作的简单方法?

I'm trying to get this simple list working, but the ul is closing and not enclosing the li elements in the loop. Am I missing a simple way to do this?

  %ul.nav.nav-tabs.nav-stacked
   - @courses.each do |c|
   %li
    = link_to "add", { :controller => "admin/relateds", :action => "edit", :id => c.id }, :confirm => "Are you sure?"
    = c.coursetitle

推荐答案

%li需要缩进,因为它位于do块中.即使它是有效标记,如果您选择使用2或4,也会为您节省调试时间缩进空间可提高可读性,因为很难辨认.

The %li needs indentation because it is within a do block. Even if it is valid markup it will save you debugging time if you opt to use 2 or 4 spaces for indentation for better legibility, as one is very difficult to discern.

%ul.nav.nav-tabs.nav-stacked
  - @courses.each do |c|
    %li
      = link_to "add", { :controller => "admin/relateds", :action => "edit", :id => c.id }, :confirm => "Are you sure?"
      = c.coursetitle

这篇关于HAML和Ruby循环以及UL不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆