Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

ContentFor ArgumentError: recursive array join #67

Closed
stylpe opened this Issue · 8 comments

5 participants

@stylpe

I tried out the ContentFor extension, but it seems to crash with an ArgumentError: recursive array join

It seems easy to reproduce, I created two files under /views:

\ test1.slim
= yield
== yield_content :test
\ test2.slim
p test2
- content_for :test do
  p test1

Then from my app.rb:

get "\test" do
  slim :test2, layout: :test1
end

Removing content_for or yield_content makes the page render without errors.

This is running on thin (1.5.0) through foreman.

@kytrinyx
Owner

I am unable to reproduce this with Sinatra version 1.3.3, SinatraContrib version 1.3.2, and running on thin 1.5.0 using erb.

@stylpe Are you still seeing this issue?

The test app I used was:

require 'sinatra/base'                                                         
require 'sinatra/content_for'                                                  

class App < Sinatra::Base                                                      
  helpers Sinatra::ContentFor                                                  

  get '/' do                                                                   
    erb :index                                                                 
  end                                                                          

end                                                                            

App.run!
# layout.erb

<%= yield %>                                                                   

<%= yield_content :test %>  
<p>Hello, World!</p>                                                      

<% content_for :test do %>                                                     
<p>Captured content</p>                                        
<% end %> 
@zzak
Owner

Without any feedback from the original author for ~9 months I must close this.

I was also unable to reproduce this with the 1.4.x series of sinatra+sinatra-contrib. Here's the example code that I used:

require 'sinatra/base'
require 'sinatra/content_for'
require 'slim'

class App < Sinatra::Base
  helpers Sinatra::ContentFor
  enable :inline_templates

  get '/test' do
    slim :test2, layout: :test1
  end

end

App.run!

__END__
@@test1
= yield
== yield_content :test

@@test2
p test2
- content_for :test do
  p test1
@zzak zzak closed this
@mperrando

This is happening to me too, using the very same code of @zzak.
May you take a look at it?

Thank you.

I attach some details, feel free to ask for more.

Platform: OS X 10.9.5.

$ ruby -v
ruby 2.1.3p242 (2014-09-19 revision 47630) [x86_64-darwin13.0]

Gemfile content

$ cat Gemfile
source 'https://rubygems.org'

gem 'sinatra'
gem 'sinatra-contrib'
gem 'sinatra-reloader', group: :development
gem 'slim'
#gem 'thin'
group :development, :test do
  gem 'cucumber'
  gem 'capybara'
  gem 'rspec-mocks'
  gem 'rspec-expectations'
end
group :development do
  gem 'guard-cucumber'
end

Gemfile.lock content

$ cat Gemfile.lock
GEM
  remote: https://rubygems.org/
  specs:
    backports (3.6.4)
    builder (3.2.2)
    capybara (2.4.4)
      mime-types (>= 1.16)
      nokogiri (>= 1.3.3)
      rack (>= 1.0.0)
      rack-test (>= 0.5.4)
      xpath (~> 2.0)
    celluloid (0.16.0)
      timers (~> 4.0.0)
    coderay (1.1.0)
    cucumber (1.3.17)
      builder (>= 2.1.2)
      diff-lcs (>= 1.1.3)
      gherkin (~> 2.12)
      multi_json (>= 1.7.5, < 2.0)
      multi_test (>= 0.1.1)
    diff-lcs (1.2.5)
    ffi (1.9.6)
    formatador (0.2.5)
    gherkin (2.12.2)
      multi_json (~> 1.3)
    guard (2.10.1)
      formatador (>= 0.2.4)
      listen (~> 2.7)
      lumberjack (~> 1.0)
      pry (>= 0.9.12)
      thor (>= 0.18.1)
    guard-cucumber (1.5.1)
      cucumber (>= 1.3.0)
      guard (>= 2.0.0)
    hitimes (1.2.2)
    listen (2.8.3)
      celluloid (>= 0.15.2)
      rb-fsevent (>= 0.9.3)
      rb-inotify (>= 0.9)
    lumberjack (1.0.9)
    method_source (0.8.2)
    mime-types (2.4.3)
    mini_portile (0.6.1)
    multi_json (1.10.1)
    multi_test (0.1.1)
    nokogiri (1.6.5)
      mini_portile (~> 0.6.0)
    pry (0.10.1)
      coderay (~> 1.1.0)
      method_source (~> 0.8.1)
      slop (~> 3.4)
    rack (1.5.2)
    rack-protection (1.5.3)
      rack
    rack-test (0.6.2)
      rack (>= 1.0)
    rb-fsevent (0.9.4)
    rb-inotify (0.9.5)
      ffi (>= 0.5.0)
    rspec-expectations (3.1.2)
      diff-lcs (>= 1.2.0, < 2.0)
      rspec-support (~> 3.1.0)
    rspec-mocks (3.1.3)
      rspec-support (~> 3.1.0)
    rspec-support (3.1.2)
    sinatra (1.4.5)
      rack (~> 1.4)
      rack-protection (~> 1.4)
      tilt (~> 1.3, >= 1.3.4)
    sinatra-contrib (1.4.2)
      backports (>= 2.0)
      multi_json
      rack-protection
      rack-test
      sinatra (~> 1.4.0)
      tilt (~> 1.3)
    sinatra-reloader (1.0)
      sinatra-contrib
    slim (2.1.0)
      temple (~> 0.6.9)
      tilt (>= 1.3.3, < 2.1)
    slop (3.6.0)
    temple (0.6.10)
    thor (0.19.1)
    tilt (1.4.1)
    timers (4.0.1)
      hitimes
    xpath (2.0.0)
      nokogiri (~> 1.3)

PLATFORMS
  ruby

DEPENDENCIES
  capybara
  cucumber
  guard-cucumber
  rspec-expectations
  rspec-mocks
  sinatra
  sinatra-contrib
  sinatra-reloader
  slim

Stack trace

ArgumentError - recursive array join:
    [...]/vendor/ruby/2.1.0/gems/sinatra-contrib-1.4.2/lib/sinatra/engine_tracking.rb:92:in `join'
    [...]/vendor/ruby/2.1.0/gems/sinatra-contrib-1.4.2/lib/sinatra/engine_tracking.rb:92:in `block in singleton class'
    [...]/vendor/ruby/2.1.0/gems/sinatra-contrib-1.4.2/lib/sinatra/engine_tracking.rb:88:in `instance_eval'
    [...]/vendor/ruby/2.1.0/gems/sinatra-contrib-1.4.2/lib/sinatra/engine_tracking.rb:88:in `singleton class'
    [...]/vendor/ruby/2.1.0/gems/sinatra-contrib-1.4.2/lib/sinatra/engine_tracking.rb:86:in `__tilt_70363944452220'
    [...]/vendor/ruby/2.1.0/gems/tilt-1.4.1/lib/tilt/template.rb:170:in `call'
    [...]/vendor/ruby/2.1.0/gems/tilt-1.4.1/lib/tilt/template.rb:170:in `evaluate'
    [...]/vendor/ruby/2.1.0/gems/tilt-1.4.1/lib/tilt/template.rb:103:in `render'
    [...]/vendor/ruby/2.1.0/gems/sinatra-1.4.5/lib/sinatra/base.rb:814:in `render'
    [...]/vendor/ruby/2.1.0/gems/sinatra-contrib-1.4.2/lib/sinatra/engine_tracking.rb:91:in `block in render'
    [...]/vendor/ruby/2.1.0/gems/sinatra-contrib-1.4.2/lib/sinatra/engine_tracking.rb:83:in `with_engine'
    [...]/vendor/ruby/2.1.0/gems/sinatra-contrib-1.4.2/lib/sinatra/engine_tracking.rb:91:in `render'
    [...]/vendor/ruby/2.1.0/gems/sinatra-contrib-1.4.2/lib/sinatra/capture.rb:110:in `capture'
    [...]/vendor/ruby/2.1.0/gems/sinatra-contrib-1.4.2/lib/sinatra/capture.rb:119:in `block (2 levels) in capture_later'
    [...]/vendor/ruby/2.1.0/gems/sinatra-contrib-1.4.2/lib/sinatra/engine_tracking.rb:83:in `with_engine'
    [...]/vendor/ruby/2.1.0/gems/sinatra-contrib-1.4.2/lib/sinatra/capture.rb:119:in `block in capture_later'
    [...]/vendor/ruby/2.1.0/gems/sinatra-contrib-1.4.2/lib/sinatra/engine_tracking.rb:91:in `block in singleton class'
    [...]/vendor/ruby/2.1.0/gems/sinatra-contrib-1.4.2/lib/sinatra/engine_tracking.rb:88:in `instance_eval'
    [...]/vendor/ruby/2.1.0/gems/sinatra-contrib-1.4.2/lib/sinatra/engine_tracking.rb:88:in `singleton class'
    [...]/vendor/ruby/2.1.0/gems/sinatra-contrib-1.4.2/lib/sinatra/engine_tracking.rb:86:in `__tilt_70363944452220'
    [...]/vendor/ruby/2.1.0/gems/tilt-1.4.1/lib/tilt/template.rb:170:in `call'
    [...]/vendor/ruby/2.1.0/gems/tilt-1.4.1/lib/tilt/template.rb:170:in `evaluate'
    [...]/vendor/ruby/2.1.0/gems/tilt-1.4.1/lib/tilt/template.rb:103:in `render'
    [...]/vendor/ruby/2.1.0/gems/sinatra-1.4.5/lib/sinatra/base.rb:814:in `render'
    [...]/vendor/ruby/2.1.0/gems/sinatra-contrib-1.4.2/lib/sinatra/engine_tracking.rb:91:in `block in render'
    [...]/vendor/ruby/2.1.0/gems/sinatra-contrib-1.4.2/lib/sinatra/engine_tracking.rb:83:in `with_engine'
    [...]/vendor/ruby/2.1.0/gems/sinatra-contrib-1.4.2/lib/sinatra/engine_tracking.rb:91:in `render'
    [...]/vendor/ruby/2.1.0/gems/sinatra-contrib-1.4.2/lib/sinatra/capture.rb:110:in `capture'
    [...]/vendor/ruby/2.1.0/gems/sinatra-contrib-1.4.2/lib/sinatra/content_for.rb:114:in `block in yield_content'
    [...]/vendor/ruby/2.1.0/gems/sinatra-contrib-1.4.2/lib/sinatra/content_for.rb:114:in `map'
    [...]/vendor/ruby/2.1.0/gems/sinatra-contrib-1.4.2/lib/sinatra/content_for.rb:114:in `yield_content'
    test.rb:20:in `block in singleton class'
    test.rb:17:in `instance_eval'
    test.rb:17:in `singleton class'
    test.rb:15:in `__tilt_70363944452220'
    [...]/vendor/ruby/2.1.0/gems/tilt-1.4.1/lib/tilt/template.rb:170:in `call'
    [...]/vendor/ruby/2.1.0/gems/tilt-1.4.1/lib/tilt/template.rb:170:in `evaluate'
    [...]/vendor/ruby/2.1.0/gems/tilt-1.4.1/lib/tilt/template.rb:103:in `render'
    [...]/vendor/ruby/2.1.0/gems/sinatra-1.4.5/lib/sinatra/base.rb:814:in `render'
    [...]/vendor/ruby/2.1.0/gems/sinatra-contrib-1.4.2/lib/sinatra/engine_tracking.rb:91:in `block in render'
    [...]/vendor/ruby/2.1.0/gems/sinatra-contrib-1.4.2/lib/sinatra/engine_tracking.rb:83:in `with_engine'
    [...]/vendor/ruby/2.1.0/gems/sinatra-contrib-1.4.2/lib/sinatra/engine_tracking.rb:91:in `render'
    [...]/vendor/ruby/2.1.0/gems/sinatra-1.4.5/lib/sinatra/base.rb:823:in `block in render'
    [...]/vendor/ruby/2.1.0/gems/sinatra-1.4.5/lib/sinatra/base.rb:823:in `catch'
    [...]/vendor/ruby/2.1.0/gems/sinatra-1.4.5/lib/sinatra/base.rb:823:in `render'
    [...]/vendor/ruby/2.1.0/gems/sinatra-contrib-1.4.2/lib/sinatra/engine_tracking.rb:91:in `block in render'
    [...]/vendor/ruby/2.1.0/gems/sinatra-contrib-1.4.2/lib/sinatra/engine_tracking.rb:83:in `with_engine'
    [...]/vendor/ruby/2.1.0/gems/sinatra-contrib-1.4.2/lib/sinatra/engine_tracking.rb:91:in `render'
    [...]/vendor/ruby/2.1.0/gems/sinatra-1.4.5/lib/sinatra/base.rb:742:in `slim'
    test.rb:10:in `block in <class:App>'
    [...]/vendor/ruby/2.1.0/gems/sinatra-1.4.5/lib/sinatra/base.rb:1603:in `call'
    [...]/vendor/ruby/2.1.0/gems/sinatra-1.4.5/lib/sinatra/base.rb:1603:in `block in compile!'
    [...]/vendor/ruby/2.1.0/gems/sinatra-1.4.5/lib/sinatra/base.rb:966:in `[]'
    [...]/vendor/ruby/2.1.0/gems/sinatra-1.4.5/lib/sinatra/base.rb:966:in `block (3 levels) in route!'
    [...]/vendor/ruby/2.1.0/gems/sinatra-1.4.5/lib/sinatra/base.rb:985:in `route_eval'
    [...]/vendor/ruby/2.1.0/gems/sinatra-1.4.5/lib/sinatra/base.rb:966:in `block (2 levels) in route!'
    [...]/vendor/ruby/2.1.0/gems/sinatra-1.4.5/lib/sinatra/base.rb:1006:in `block in process_route'
    [...]/vendor/ruby/2.1.0/gems/sinatra-1.4.5/lib/sinatra/base.rb:1004:in `catch'
    [...]/vendor/ruby/2.1.0/gems/sinatra-1.4.5/lib/sinatra/base.rb:1004:in `process_route'
    [...]/vendor/ruby/2.1.0/gems/sinatra-1.4.5/lib/sinatra/base.rb:964:in `block in route!'
    [...]/vendor/ruby/2.1.0/gems/sinatra-1.4.5/lib/sinatra/base.rb:963:in `each'
    [...]/vendor/ruby/2.1.0/gems/sinatra-1.4.5/lib/sinatra/base.rb:963:in `route!'
    [...]/vendor/ruby/2.1.0/gems/sinatra-1.4.5/lib/sinatra/base.rb:1076:in `block in dispatch!'
    [...]/vendor/ruby/2.1.0/gems/sinatra-1.4.5/lib/sinatra/base.rb:1058:in `block in invoke'
    [...]/vendor/ruby/2.1.0/gems/sinatra-1.4.5/lib/sinatra/base.rb:1058:in `catch'
    [...]/vendor/ruby/2.1.0/gems/sinatra-1.4.5/lib/sinatra/base.rb:1058:in `invoke'
    [...]/vendor/ruby/2.1.0/gems/sinatra-1.4.5/lib/sinatra/base.rb:1073:in `dispatch!'
    [...]/vendor/ruby/2.1.0/gems/sinatra-1.4.5/lib/sinatra/base.rb:898:in `block in call!'
    [...]/vendor/ruby/2.1.0/gems/sinatra-1.4.5/lib/sinatra/base.rb:1058:in `block in invoke'
    [...]/vendor/ruby/2.1.0/gems/sinatra-1.4.5/lib/sinatra/base.rb:1058:in `catch'
    [...]/vendor/ruby/2.1.0/gems/sinatra-1.4.5/lib/sinatra/base.rb:1058:in `invoke'
    [...]/vendor/ruby/2.1.0/gems/sinatra-1.4.5/lib/sinatra/base.rb:898:in `call!'
    [...]/vendor/ruby/2.1.0/gems/sinatra-1.4.5/lib/sinatra/base.rb:886:in `call'
    [...]/vendor/ruby/2.1.0/gems/rack-protection-1.5.3/lib/rack/protection/xss_header.rb:18:in `call'
    [...]/vendor/ruby/2.1.0/gems/rack-protection-1.5.3/lib/rack/protection/path_traversal.rb:16:in `call'
    [...]/vendor/ruby/2.1.0/gems/rack-protection-1.5.3/lib/rack/protection/json_csrf.rb:18:in `call'
    [...]/vendor/ruby/2.1.0/gems/rack-protection-1.5.3/lib/rack/protection/base.rb:49:in `call'
    [...]/vendor/ruby/2.1.0/gems/rack-protection-1.5.3/lib/rack/protection/base.rb:49:in `call'
    [...]/vendor/ruby/2.1.0/gems/rack-protection-1.5.3/lib/rack/protection/frame_options.rb:31:in `call'
    [...]/vendor/ruby/2.1.0/gems/rack-1.5.2/lib/rack/nulllogger.rb:9:in `call'
    [...]/vendor/ruby/2.1.0/gems/rack-1.5.2/lib/rack/head.rb:11:in `call'
    [...]/vendor/ruby/2.1.0/gems/sinatra-1.4.5/lib/sinatra/show_exceptions.rb:21:in `call'
    [...]/vendor/ruby/2.1.0/gems/sinatra-1.4.5/lib/sinatra/base.rb:180:in `call'
    [...]/vendor/ruby/2.1.0/gems/sinatra-1.4.5/lib/sinatra/base.rb:2014:in `call'
    [...]/vendor/ruby/2.1.0/gems/sinatra-1.4.5/lib/sinatra/base.rb:1478:in `block in call'
    [...]/vendor/ruby/2.1.0/gems/sinatra-1.4.5/lib/sinatra/base.rb:1788:in `synchronize'
    [...]/vendor/ruby/2.1.0/gems/sinatra-1.4.5/lib/sinatra/base.rb:1478:in `call'
    [...]/vendor/ruby/2.1.0/gems/rack-1.5.2/lib/rack/handler/webrick.rb:60:in `service'
    /usr/local/rvm/rubies/ruby-2.1.3/lib/ruby/2.1.0/webrick/httpserver.rb:138:in `service'
    /usr/local/rvm/rubies/ruby-2.1.3/lib/ruby/2.1.0/webrick/httpserver.rb:94:in `run'
    /usr/local/rvm/rubies/ruby-2.1.3/lib/ruby/2.1.0/webrick/server.rb:295:in `block in start_thread'
localhost - - [04/Dec/2014:10:15:31 CET] "GET /test HTTP/1.1" 500 248575
- -> /test
@mperrando

Problem is showing with ruby 1.9.3 too.

$ ruby -v
ruby 1.9.3p392 (2013-02-22 revision 39386) [x86_64-darwin12.2.0]
@mperrando

Just another update.
Same beahaviour on linux Debian and ruby 2.1.2

$ uname -a
Linux XXXX 3.2.0-4-686-pae #1 SMP Debian 3.2.63-2+deb7u1 i686 GNU/Linux
$ ruby -v
ruby 2.1.2p95 (2014-05-08 revision 45877) [i686-linux]
@mperrando

@zzak, @kytrinyx , which is the exact environemnt and gems where this thing is working for you?

Thank you.

@supermario

Was just having this issue as well, and it appears to be resolvable by not using slim within the block:

- content_for :title do
  - 'test'

Which is strange, given that there are a number of content_for specs with a similar syntax:

https://github.com/sinatra/sinatra-contrib/blob/master/spec/content_for/different_key.slim

I was simply using slim with dashing:

source 'https://rubygems.org'
gem 'dashing'
gem 'slim'
@mperrando

As a workaround, add to your Gemfile the line

gem 'temple', '<=0.6.8'

And now the long explanation.

I tried to setup an environemnt reproducing this "green" Travis build.

All the tests involving yield_content failed!

Comparing the installed gems in my enviroment and the ones in the Travis list, I noticed some differences.

So I tried to manually find a working combaination of gems. After a few hours, I've found that specyfing in the Gemfile the 0.6.8 version of the temple gem solves the problem.

So the problem semms to be due to changes between temple versione 0.6.8 and 0.6.9. This is the comparison

Hope this can help for fixing the issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.