slim-template / slim

Slim is a template language whose goal is to reduce the syntax to the essential parts without becoming cryptic.
https://slim-template.github.io
MIT License
5.29k stars 500 forks source link

Weird behavior in rails 7.1 #944

Closed la-magra closed 8 months ago

la-magra commented 8 months ago

I just took over an old rails application and after doing upgrade tests from rails 7.0 to rails 7.1, the following code seems to throw the following error:

/ app/views/layouts/application.html.slim
doctype html                                                                                                                                                                                                 
html                                                                                                                                                                                                         
  body                                                                                                                                                                                                       
    = render 'layouts/nav'
/ app/views/layouts/_nav.html.slim
a.dropdown.test aria={ haspopup: true }

rspec run:

 1) Page displays correctly                            
     Failure/Error: a.dropdown.test aria={ haspopup: true }                             

     ActionView::Template::Error:                                                                        
       undefined method `+' for #<ActionView::OutputBuffer:0x00007f2a53f95c98 @raw_buffer="dropdown">
     # /home/****/.gem/ruby/3.2.2/gems/slim-5.1.1/lib/slim/splat/builder.rb:37:in `attr'                                                                                                                           
     # ./app/views/layouts/_nav.html.slim:2:in `_app_views_layouts__nav_html_slim___3302332766990303534_69000'                                                                                                     
     # ./app/views/layouts/application.html.slim:23:in `_app_views_layouts_application_html_slim___3139811637334119039_68960'  
...                                                                                                               
     # ------------------                                                                                
     # --- Caused by: ---                                                                                
     # NoMethodError:                                                                                    
     #   undefined method `+' for #<ActionView::OutputBuffer:0x00007f2a53f95c98 @raw_buffer="dropdown">
     #   /home/********/.gem/ruby/3.2.2/gems/slim-5.1.1/lib/slim/splat/builder.rb:37:in `attr'

So far we've narrowed the problem by removing one class or the aria:

a.dropdown.test aria={ haspopup: true }  # BREAKS
a.dropdown aria={ haspopup: true }         # WORKS
a.dropdown.test                        # WORKS
a.test aria={ haspopup: true }       # WORKS

Issue happens with all current rails 7.1.* , we also made tests on rails branch 7-1-stable as specified in #943 with no changes.

The abbreviated gemfile.lock is:

# Gemfile.lock abreviated
GIT                                                                                                                                                                                                                
  remote: https://github.com/rails/rails.git                                                                                                                                                                       
  revision: 1c8598556afde186b4f60e2fd5948763b7309ba5                                                                                                                                                               
  branch: 7-1-stable                                                                                                                                                                                               
  specs:                                                                                                                                                                                                           
    rails (7.1.1)                                                                                                                                                                                                  
      actioncable (= 7.1.1)                                                                                                                                                                                        
      actionmailbox (= 7.1.1)                                                                                                                                                                                      
      actionmailer (= 7.1.1)                                                                                                                                                                                       
      actionpack (= 7.1.1)                                                                                                                                                                                         
      actiontext (= 7.1.1)                                                                                                                                                                                         
      actionview (= 7.1.1)                                                                                                                                                                                         
      activejob (= 7.1.1)                                                                                                                                                                                          
      activemodel (= 7.1.1)                                                                                                                                                                                        
      activerecord (= 7.1.1)                                                                                                                                                                                       
      activestorage (= 7.1.1)                                                                                                                                                                                      
      activesupport (= 7.1.1)                                                                                                                                                                                      
      bundler (>= 1.15.0)                                                                                                                                                                                          
      railties (= 7.1.1) 

GEM
...
    slim (5.1.1)                                                                                                                                                                                                   
      temple (~> 0.10.0)                                                                                                                                                                                           
      tilt (>= 2.1.0)                                                                                                                                                                                              
    slim-rails (3.6.2)                                                                                                                                                                                             
      actionpack (>= 3.1)                                                                                                                                                                                          
      railties (>= 3.1)                                                                                                                                                                                            
      slim (>= 3.0, < 6.0, != 5.0.0)  
...
minad commented 8 months ago

This is a duplicate of #941 and #942.