【问题标题】:HAML error, ruby 1.9.3 on rails 3. syntax error, unexpected keyword_ensure, expecting $endHAML 错误,ruby 1.9.3 on rails 3. 语法错误,意外关键字_ensure,期待 $end
【发布时间】:2012-05-01 06:56:29
【问题描述】:

我不断收到此错误:

Showing app/views/posts/index.html.haml where line #115 raised:

app/views/posts/index.html.haml:115: syntax error, unexpected keyword_ensure, 
expecting $end

Extracted source (around line #115):

0

Trace of template inclusion: app/views/posts/index.html.haml

Application Trace | Framework Trace | Full Trace

app/controllers/posts_controller.rb:28:in `index'

这是 index.html.haml 文件:

.container-fluid
%br 
.row-fluid 
    .span3 
        .well.sidebar-nav{:style=>'background-color:rgb(999,999,999);'}
            %ul.nav.nav-pills.nav-stacked 
                %li
                    %a{:href => '#'} Todays Best 
                %li 
                    %a{:href => '#'} Yesterdays Best 
                %li 
                    %a{:href => '#'} Weeks Best 
                %li 
                    %a{:href => '#'} Months Best 
                %li 
                    %a{:href => '#'} Hall of Fame 
        .label.label-inverse
            %center
                Todays Best: 
        %table.table.table-bordered.table-condensed{:style=>'background-color:rgb(999,999,999);'}
            - @count= 0
            - @feedcount= 4 #5 best
            - @popularfeed.each do |post|
                - if @count<=@feedcount then
                    %tr
                        %td
                            %center
                                =  truncate(post.content, :length => 132)
                                -  @count= @count +1
                                %br
                            %p{:align => "right"}
                                %span{:style=>'color:green;'}=post.likes
                                %span{:style=>'color:red;'}=post.dislikes
                                %span{:style=>'color:blue;'}=post.prominence
    .span6 
        %center
            %table.table.table-bordered.table-condensed{:style=>'background-color:rgb(999,999,999);'}
            - @mainfeed.each do |post|
                =link_to post do 
                    %tr
                        %td  
                            %center
                                %br
                                =post.content   
                            %p.small{:align => 'right'}
                                3 days ago
                            %center  



                                %span.labelStyle.label.label-success
                                    =link_to 'Agree', :action  =>   'like', :id  =>   post.id
                                    =post.likes 
                                %span.label.label-important.postbar 
                                    =link_to 'Disagree', :action  =>   'dislike', :id  =>   post.id
                                    =post.dislikes 
                                %span.label.label-info.postbar 
                                    =link_to 'Voice', :action => 'prominence', :id  =>  post.id
                                    =post.prominence
                                %span.label.postbar 
                                    %a{:'data-toggle'=>"modal", :'data-target'=>"#myModal"}
                                        Comments
                                        =post.comments.count

                                %span.label.postbar 
                                    Report
                                %br 
                                %br 
                                %tr
                    %td
                        %p
                            %a.btn{:href => '#'} View details &raquo; 
    .span3
        .well{:style=>'background-color:rgb(999,999,999);'}
            =render 'form'  
        -#  .alert.alert-success 
        -#      Post was succesfully made.
    .span3
        .label.label-inverse
            %center Most Controversial:                  
        %table.table.table-bordered.table-condensed{:style=>'background-color:rgb(999,999,999);'}
            - @count= 0            
            - @feedcount= 3  #3 best 
            - @controfeed.each do |post|
                - if @count<=@feedcount then  
                    %tr                                 
                        %td                                       
                            %center                                         
                                =truncate(post.content, :length => 132)             
                                -@count= @count +1
                                %br                                                     
                            %p{:align => "right"}
                                %span{:style=>'color:green;'}=post.likes              
                                %span{:style=>'color:red;'}=post.dislikes     
                                %span{:style=>'color:blue;'}=post.prominence

我认为错误应该在 .span6 中,但我不确定。此文件只有 112 行长,错误在第 115 行。感谢帮助

【问题讨论】:

  • 代码看起来没问题。把它切成两半,找到有错误的行。然后再次切,直到找到确切的位置。

标签: ruby-on-rails ruby haml


【解决方案1】:

您在 116 和 177 上有两个没有以 - 为前缀的 cmets(或者至少,我认为您在代码中进行了评论)

#3 best 和 #5 best 可能需要变为 -#3best 和 -#5best

【讨论】:

    猜你喜欢
    • 2013-07-15
    • 2012-02-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多