简体   繁体   English

HAML循环绑定晚了部分

[英]HAML loop binding late for partials

I'm trying to put loop as partial inside loop like below: 我试图将循环作为部分内部循环,如下所示:

%ul
- halls.each do |hall, children|
    %li
        = link_to_unless_current hall.name, hall
        = render partial: 'hall_structure', :locals => { halls: children } if children.present?

Partial hall_structure: 大厅部分结构:

%ul
- halls.each do |hall, children|
    %li
        = link_to_unless_current hall.name, hall
        = render partial: 'hall_structure', :locals => { halls: children } if children.present?

But somehow the output is like this: 但是以某种方式的输出是这样的:

<ul>
                      <li>
                        <a href="/halls/5">Main Hall</a>
                        <ul></ul>
                        </li><li>
                          <a href="/halls/1">Conference Hall</a>

                        </li>
                        <li>
                          <a href="/halls/4">Exhibition Hall</a>

                        </li>

                    </ul>

Is there a reason why it's not putting in partial loop as inner loop under the first li ? 是否有理由不将部分循环作为第一个li下的内部循环?

Maybe the indentation? 也许缩进?

%ul
  - halls.each do |hall, children|

Also make sure that's the real output. 还要确保这是真实的输出。 Not the final xml that your browser rendered. 不是您的浏览器呈现的最终xml。 Many web browsers try to fix mal formed html. 许多网络浏览器尝试修复格式错误的html。 And it seems to me it might be happening here. 在我看来,这可能正在发生。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM