0
我試圖創建一個網格幫手,我使用此代碼:Ruby on Rails的幫手創建網格
module ApplicationHelper
def grid_helper(names)
names.each_slice(2) do |name1, name2|
haml_tag 'div', class: 'column' do
haml_tag 'div', class: 'thumb' do
haml_concat link_to name1[:url] do
image_tag name1[:thumb], alt: name1[:description], size: '36x36'
end
end
haml_tag 'div', class: 'thumb' do
haml_concat link_to name2[:url] do
image_tag name2[:thumb], alt: name2[:description], size: '36x36'
end
end
end
end
end
end
:
在app /傭工/ application_helper.rb 呼籲HAML:
#mydiv
- games = [{thumb: 'foo', description: 'foobar', url: 'foo'}, {thumb: 'bar', description: 'foobarbaz', url: 'bar'}]
- grid_helper(games)
所以這個放於HTML:
<div class="column">
<div class="thumb">
<a href="/">foo</a>
</div>
<div class="thumb">
<a href="/">bar</a>
</div>
</div>
的link_to
不正常工作和image_tag
真正做到我的幫手沒有作品,有人能幫忙嗎?
觀測值:我使用Rails4,Ruby2和SASS/HAML
刪除'p'之前'link_to' – Baldrick
@Baldrick刪除,但這改變不了什麼:/ –