[email protected] do |thing|
%div.thing
= thing
我看过几种不同的技术。但是,使用上述HAML模板,我希望每个对象thing
都有一个从1到n + 1的唯一ID 。为所有个人动态增加ID的最佳方法是things
什么?
例如:对于n件事,我希望HTML看起来像这样。
<div class='thing' id='1'>
<div class='thing' id='2'>
...
<div class='thing' id=n+1>
[email protected]_with_index do |thing,index|
%div.thing{:id => "thing#{index}"}
= thing
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句