2016-04-17 21 views
-3

私はRuby on Railsの初心者です。 私がコンパイルし、ブラウザ上で、それはちょうど私index.hamlRuby on Rails、Haml :: SyntaxError at/

HAMLで同じエラー::/ 違法ネスティングのにSyntaxErrorを保持します:プレーンテキストの中に入れ子にすることは違法です。

enter image description here

これは私がオンライン見上げるとき、私は解決策を見つけることができませんでしたコード、

%h1.text-center All images 
.row 
%ul.list-unstyled 
@images.each do |image| 
    %li 
    %h2=image.title 

    %p 
     %a.thumbnail{href: image.file, data:{ lightbox: "gallery", title: image.title } } 
     %img{src: image.file.url(:small), width: "100%"} 

    %p 
     %span(class='st_facebook_hcount' displayText='Facebook' st_url="#{request.base_url}/images/#{image.id}") 
     %span(class='st_twitter_hcount' displayText='Tweet' st_url="#{request.base_url}/images/#{image.id}") 

です。 この問題を解決するにはどうすればよいですか?

ありがとうございます。

+0

ご質問はありますか? – sawa

答えて

1

tell Haml to evaluate the line as Ruby codeとなるダッシュ(-)がありません。現在、@images.each do |image|がプレーンテキストとして表示されています。変更:

%h1.text-center All images 
.row 
    %ul.list-unstyled 
    - @images.each do |image| 
     %li 
     %h2=image.title 

     %p 
     %a.thumbnail{href: image.file, data:{ lightbox: "gallery", title: image.title } } 
     %img{src: image.file.url(:small), width: "100%"} 

     %p 
     %span(class='st_facebook_hcount' displayText='Facebook' st_url="#{request.base_url}/images/#{image.id}") 
     %span(class='st_twitter_hcount' displayText='Tweet' st_url="#{request.base_url}/images/#{image.id}") 
+0

@dukejがこれはあなたにとって問題でしたか? –