So I've written this code for erb awhile ago
<% if @posting.pictures.blank? %>
<% else %>
<script>
$("#slider-posting").vegas({
slides: [
<%- @posting.pictures.each do |p| %>
{src: '<%=p.url%>'},
<%- end %>
],
transition: 'slideLeft'
});
</script>
<% end %>
I'm having a bit of trouble converting it to HAML.
Trying conversion based on http://html2haml.herokuapp.com/
- if @posting.pictures.blank?
- else
:javascript
$("#slider-posting").vegas({
slides: [
<haml_silent> @posting.pictures.each do |p|
</haml_silent><haml_block> {src: '#{p.url}'},
</haml_block> ],
transition: 'slideLeft'
});
Causes the following error
undefined method `url' for nil:NilClass
on this line
</haml_silent><haml_block> {src: '#{p.url}'},