In a Sinatra script, I have code that checks if a file exists, then shows it with the proper rendering. The files are located under \views:
get '/:page' do
if File.exists?('views/'+params[:page]+'.slim')
slim params[:page].to_sym
else
raise error(404)
end
end
I want these files in \public. How do I do this please?:
get '/:page' do
if File.exists?('public/'+params[:page]+'.slim')
slim "/public/"+params[:page].to_sym #=> error
else
raise error(404)
end
end
Nevermind, I found it: