0
我正在我的紅寶石的第一步,我想學習如何使用Sinatra。在一本相關的書中,我發現了用Slim編寫的這個示例視圖。轉換苗條ERB
h1 Songs
a href="/songs/new" Create a new song
- if @songs.any?
ul#songs
[email protected] do |song|
li <a href="/songs/#{song.id}">#{song.title}</a>
- else
p No songs have been created yet!
我試圖把它變成ERB在這樣的
<html>
<h1> Songs </h1>
<a href="/songs/new" Create a new song></a>
<% if @songs.any? %>
<%#songs%>
<% @songs.each do |song|%>
<ul><li> <a href="/songs/#{song.id}"><%=#{song.title}%></a></li></ul>
<% else %>
<p> No songs have been created yet!</p>
<% end %>
</html>
西納特拉結束了給了我這個報告
SyntaxError at /songs
Documents/programs/sinatra/views/songs.erb:8: syntax error, unexpected keyword_else, expecting ')' ; else^
Documents/programs/sinatra/views/songs.erb:10: syntax error, unexpected keyword_end, expecting ')' ; end ; @_out_buf.concat "\t\n"^
Documents/programs/sinatra/views/songs.erb:14: syntax error, unexpected keyword_ensure, expecting ')'
Documents/programs/sinatra/views/songs.erb:16: syntax error, unexpected keyword_end, expecting ')'
你能給我是怎麼回事的線索? 預先感謝您。
非常感謝你Dylan.You一直很有幫助! –