JGallardo JGallardo - 4 months ago 8
Ruby Question

What is the proper way of naming slim files using numbers for a Sinatra project?

In my Sinatra app, I am getting an error

syntax error, unexpected tINTEGER, expecting tSTRING_CONTENT or tSTRING_DBEG or tSTRING_DVAR or tSTRING_END


when I try to name my files something like 1.slim but not getting the error when I do something like this like calling it page1.slim

This is how I had my route that gave me an error

main.rb



get '/1' do
slim :1
end


but it works fine when I do something like

get '/1' do
slim :page1
end


What's the problem? in Ruby apps can I not name a view starting with a number?

Answer

It's not about view, slim or something else. it's a symbol thing.

:1 #syntax error

You can do that like

:"1"

In your case, the route would look like

get '/1' do
  slim :"1"
end