Skip to content

Instantly share code, notes, and snippets.

@betrue12
Created August 31, 2018 00:41
Show Gist options
  • Save betrue12/d1cfdd858669889b6c9cb24ebf950f72 to your computer and use it in GitHub Desktop.
Save betrue12/d1cfdd858669889b6c9cb24ebf950f72 to your computer and use it in GitHub Desktop.
For Slim issue
require 'sinatra'
require 'slim'
require 'slim/include'
set :bind, '0.0.0.0'
get '/' do
slim :index
end
doctype html
html
head
title Slim Examples
javascript:
alert('Slim supports embedded javascript!')
body
h1 Markup examples
#content
p This example shows you how a basic Slim file looks.
2018-08-31 00:35:43 - ArgumentError - wrong number of arguments (given 3, expected 2):
/var/lib/gems/2.5.0/gems/slim-4.0.0/lib/slim/filter.rb:16:in `on_slim_embedded'
/var/lib/gems/2.5.0/gems/temple-0.8.0/lib/temple/mixins/dispatcher.rb:89:in `dispatcher'
/var/lib/gems/2.5.0/gems/temple-0.8.0/lib/temple/mixins/dispatcher.rb:49:in `compile'
/var/lib/gems/2.5.0/gems/temple-0.8.0/lib/temple/mixins/dispatcher.rb:7:in `block in on_multi'
/var/lib/gems/2.5.0/gems/temple-0.8.0/lib/temple/mixins/dispatcher.rb:7:in `each'
/var/lib/gems/2.5.0/gems/temple-0.8.0/lib/temple/mixins/dispatcher.rb:7:in `on_multi'
/var/lib/gems/2.5.0/gems/temple-0.8.0/lib/temple/mixins/dispatcher.rb:110:in `dispatcher'
/var/lib/gems/2.5.0/gems/temple-0.8.0/lib/temple/mixins/dispatcher.rb:49:in `compile'
/var/lib/gems/2.5.0/gems/temple-0.8.0/lib/temple/html/dispatcher.rb:27:in `on_html_tag'
/var/lib/gems/2.5.0/gems/slim-4.0.0/lib/slim/include.rb:13:in `on_html_tag'
/var/lib/gems/2.5.0/gems/temple-0.8.0/lib/temple/mixins/dispatcher.rb:70:in `dispatcher'
/var/lib/gems/2.5.0/gems/temple-0.8.0/lib/temple/mixins/dispatcher.rb:49:in `compile'
/var/lib/gems/2.5.0/gems/temple-0.8.0/lib/temple/mixins/dispatcher.rb:7:in `block in on_multi'
/var/lib/gems/2.5.0/gems/temple-0.8.0/lib/temple/mixins/dispatcher.rb:7:in `each'
/var/lib/gems/2.5.0/gems/temple-0.8.0/lib/temple/mixins/dispatcher.rb:7:in `on_multi'
/var/lib/gems/2.5.0/gems/temple-0.8.0/lib/temple/mixins/dispatcher.rb:110:in `dispatcher'
/var/lib/gems/2.5.0/gems/temple-0.8.0/lib/temple/mixins/dispatcher.rb:49:in `compile'
/var/lib/gems/2.5.0/gems/temple-0.8.0/lib/temple/html/dispatcher.rb:27:in `on_html_tag'
/var/lib/gems/2.5.0/gems/slim-4.0.0/lib/slim/include.rb:13:in `on_html_tag'
/var/lib/gems/2.5.0/gems/temple-0.8.0/lib/temple/mixins/dispatcher.rb:70:in `dispatcher'
/var/lib/gems/2.5.0/gems/temple-0.8.0/lib/temple/mixins/dispatcher.rb:49:in `compile'
/var/lib/gems/2.5.0/gems/temple-0.8.0/lib/temple/mixins/dispatcher.rb:7:in `block in on_multi'
/var/lib/gems/2.5.0/gems/temple-0.8.0/lib/temple/mixins/dispatcher.rb:7:in `each'
/var/lib/gems/2.5.0/gems/temple-0.8.0/lib/temple/mixins/dispatcher.rb:7:in `on_multi'
/var/lib/gems/2.5.0/gems/temple-0.8.0/lib/temple/mixins/dispatcher.rb:110:in `dispatcher'
/var/lib/gems/2.5.0/gems/temple-0.8.0/lib/temple/mixins/dispatcher.rb:69:in `replace_dispatcher'
/var/lib/gems/2.5.0/gems/temple-0.8.0/lib/temple/mixins/dispatcher.rb:55:in `dispatcher'
/var/lib/gems/2.5.0/gems/temple-0.8.0/lib/temple/mixins/dispatcher.rb:49:in `compile'
/var/lib/gems/2.5.0/gems/temple-0.8.0/lib/temple/mixins/dispatcher.rb:45:in `call'
/var/lib/gems/2.5.0/gems/temple-0.8.0/lib/temple/engine.rb:50:in `block in call'
/var/lib/gems/2.5.0/gems/temple-0.8.0/lib/temple/engine.rb:50:in `each'
/var/lib/gems/2.5.0/gems/temple-0.8.0/lib/temple/engine.rb:50:in `inject'
/var/lib/gems/2.5.0/gems/temple-0.8.0/lib/temple/engine.rb:50:in `call'
/var/lib/gems/2.5.0/gems/slim-4.0.0/lib/slim/include.rb:52:in `block in call'
/var/lib/gems/2.5.0/gems/slim-4.0.0/lib/slim/include.rb:52:in `catch'
/var/lib/gems/2.5.0/gems/slim-4.0.0/lib/slim/include.rb:52:in `call'
/var/lib/gems/2.5.0/gems/temple-0.8.0/lib/temple/mixins/template.rb:10:in `compile'
/var/lib/gems/2.5.0/gems/temple-0.8.0/lib/temple/templates/tilt.rb:30:in `prepare'
/var/lib/gems/2.5.0/gems/tilt-2.0.8/lib/tilt/template.rb:99:in `initialize'
/var/lib/gems/2.5.0/gems/sinatra-2.0.3/lib/sinatra/base.rb:878:in `new'
/var/lib/gems/2.5.0/gems/sinatra-2.0.3/lib/sinatra/base.rb:878:in `block in compile_template'
/var/lib/gems/2.5.0/gems/tilt-2.0.8/lib/tilt.rb:104:in `block in fetch'
/var/lib/gems/2.5.0/gems/tilt-2.0.8/lib/tilt.rb:103:in `fetch'
/var/lib/gems/2.5.0/gems/tilt-2.0.8/lib/tilt.rb:103:in `fetch'
/var/lib/gems/2.5.0/gems/sinatra-2.0.3/lib/sinatra/base.rb:857:in `compile_template'
/var/lib/gems/2.5.0/gems/sinatra-2.0.3/lib/sinatra/base.rb:838:in `render'
/var/lib/gems/2.5.0/gems/sinatra-2.0.3/lib/sinatra/base.rb:759:in `slim'
app.rb:6:in `block in <main>'
/var/lib/gems/2.5.0/gems/sinatra-2.0.3/lib/sinatra/base.rb:1635:in `call'
/var/lib/gems/2.5.0/gems/sinatra-2.0.3/lib/sinatra/base.rb:1635:in `block in compile!'
/var/lib/gems/2.5.0/gems/sinatra-2.0.3/lib/sinatra/base.rb:992:in `block (3 levels) in route!'
/var/lib/gems/2.5.0/gems/sinatra-2.0.3/lib/sinatra/base.rb:1011:in `route_eval'
/var/lib/gems/2.5.0/gems/sinatra-2.0.3/lib/sinatra/base.rb:992:in `block (2 levels) in route!'
/var/lib/gems/2.5.0/gems/sinatra-2.0.3/lib/sinatra/base.rb:1040:in `block in process_route'
/var/lib/gems/2.5.0/gems/sinatra-2.0.3/lib/sinatra/base.rb:1038:in `catch'
/var/lib/gems/2.5.0/gems/sinatra-2.0.3/lib/sinatra/base.rb:1038:in `process_route'
/var/lib/gems/2.5.0/gems/sinatra-2.0.3/lib/sinatra/base.rb:990:in `block in route!'
/var/lib/gems/2.5.0/gems/sinatra-2.0.3/lib/sinatra/base.rb:989:in `each'
/var/lib/gems/2.5.0/gems/sinatra-2.0.3/lib/sinatra/base.rb:989:in `route!'
/var/lib/gems/2.5.0/gems/sinatra-2.0.3/lib/sinatra/base.rb:1097:in `block in dispatch!'
/var/lib/gems/2.5.0/gems/sinatra-2.0.3/lib/sinatra/base.rb:1076:in `block in invoke'
/var/lib/gems/2.5.0/gems/sinatra-2.0.3/lib/sinatra/base.rb:1076:in `catch'
/var/lib/gems/2.5.0/gems/sinatra-2.0.3/lib/sinatra/base.rb:1076:in `invoke'
/var/lib/gems/2.5.0/gems/sinatra-2.0.3/lib/sinatra/base.rb:1094:in `dispatch!'
/var/lib/gems/2.5.0/gems/sinatra-2.0.3/lib/sinatra/base.rb:924:in `block in call!'
/var/lib/gems/2.5.0/gems/sinatra-2.0.3/lib/sinatra/base.rb:1076:in `block in invoke'
/var/lib/gems/2.5.0/gems/sinatra-2.0.3/lib/sinatra/base.rb:1076:in `catch'
/var/lib/gems/2.5.0/gems/sinatra-2.0.3/lib/sinatra/base.rb:1076:in `invoke'
/var/lib/gems/2.5.0/gems/sinatra-2.0.3/lib/sinatra/base.rb:924:in `call!'
/var/lib/gems/2.5.0/gems/sinatra-2.0.3/lib/sinatra/base.rb:913:in `call'
/var/lib/gems/2.5.0/gems/rack-protection-2.0.3/lib/rack/protection/xss_header.rb:18:in `call'
/var/lib/gems/2.5.0/gems/rack-protection-2.0.3/lib/rack/protection/path_traversal.rb:16:in `call'
/var/lib/gems/2.5.0/gems/rack-protection-2.0.3/lib/rack/protection/json_csrf.rb:26:in `call'
/var/lib/gems/2.5.0/gems/rack-protection-2.0.3/lib/rack/protection/base.rb:50:in `call'
/var/lib/gems/2.5.0/gems/rack-protection-2.0.3/lib/rack/protection/base.rb:50:in `call'
/var/lib/gems/2.5.0/gems/rack-protection-2.0.3/lib/rack/protection/frame_options.rb:31:in `call'
/var/lib/gems/2.5.0/gems/rack-2.0.5/lib/rack/logger.rb:15:in `call'
/var/lib/gems/2.5.0/gems/rack-2.0.5/lib/rack/common_logger.rb:33:in `call'
/var/lib/gems/2.5.0/gems/sinatra-2.0.3/lib/sinatra/base.rb:231:in `call'
/var/lib/gems/2.5.0/gems/sinatra-2.0.3/lib/sinatra/base.rb:224:in `call'
/var/lib/gems/2.5.0/gems/rack-2.0.5/lib/rack/head.rb:12:in `call'
/var/lib/gems/2.5.0/gems/rack-2.0.5/lib/rack/method_override.rb:22:in `call'
/var/lib/gems/2.5.0/gems/sinatra-2.0.3/lib/sinatra/show_exceptions.rb:22:in `call'
/var/lib/gems/2.5.0/gems/sinatra-2.0.3/lib/sinatra/base.rb:194:in `call'
/var/lib/gems/2.5.0/gems/sinatra-2.0.3/lib/sinatra/base.rb:1958:in `call'
/var/lib/gems/2.5.0/gems/sinatra-2.0.3/lib/sinatra/base.rb:1502:in `block in call'
/var/lib/gems/2.5.0/gems/sinatra-2.0.3/lib/sinatra/base.rb:1729:in `synchronize'
/var/lib/gems/2.5.0/gems/sinatra-2.0.3/lib/sinatra/base.rb:1502:in `call'
/var/lib/gems/2.5.0/gems/rack-2.0.5/lib/rack/handler/webrick.rb:86:in `service'
/usr/lib/ruby/2.5.0/webrick/httpserver.rb:140:in `service'
/usr/lib/ruby/2.5.0/webrick/httpserver.rb:96:in `run'
/usr/lib/ruby/2.5.0/webrick/server.rb:307:in `block in start_thread'
@betrue12
Copy link
Author

@stonean
Copy link

stonean commented Aug 31, 2018

@betrue12 thanks for reporting. The issue is with require 'slim/include', which you aren't leveraging in the example. Remove that require statement and your code works. https://travis-ci.org/slim-template/slim/builds/423050843

However, there is an issue with require 'slim/include' I need to address. I will write another test and corresponding fix.

Side note: I've copied the Sinatra Slim tests into this repo to remove the external dependency and start adding specific use cases like this one.

@betrue12
Copy link
Author

betrue12 commented Sep 1, 2018

@stonean Sorry for confusing, too simple example code. Actually, I found this error in my another Sinatra app using include.

I see your commit fixing it, Thank you for the quickest work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment