0

I'm fairly new to Ruby/Sinatra/Rack. Been using MiddlemanApp for a couple months.

I have a need for a couple of PHP pages in my middleman static site. And I'd like to be able to preview those pages in the browser while running middleman server. I don't need the PHP file to be parsed or processed, just served up as is in the preview server and with a Content-type of text/html.

In an Apache config, it's easy to tell Apache to treat a given file extension as another type of file. But I don't know where to even start on this in Sinatra/Middleman/Rack.

So:

Can I set Sinatra or Rack to serve up PHP files as static HTML? I don't want or expect Sinatra/Rack to parse the PHP. I just want the PHP embedded/untouched as static HTML when running middleman server.

I know that I can run middleman build and use Apache to serve and parse those files, but it's simply tedious to middleman build every 20 seconds.

EDIT

Ok, so I do realize that the above IS the default behavior. I'll amend my question to this:

  • How do I get Sinatra in Middleman App to serve index.php as the index file in the preview server?

Say I have source/test/index.php.erb and no source/test/index.html.erb. I'd like middleman server to serve up the /test/index.php on requests for /test/.

jevets
  • 23
  • 3

1 Answers1

0

Not exactly sure what your question is, but do you mean something like this?

get '/test' do 
  erb :'test/index.php'
end

Where you have a file named index.php.erb in your views/test folder

AlexQueue
  • 6,353
  • 5
  • 35
  • 44
  • Yes, I was hoping something like that would work. But middleman doesn't seem to like the `get` stuff in there. (Sorry my question got a bit out of hand) – jevets Feb 08 '13 at 20:09
  • @jevets I don't know much about the Middleman App but you can serve static files by putting them in your 'public' folder. Place index.php in public/test and you can get it from example.com/test/index.php – AlexQueue Feb 08 '13 at 20:12
  • thanks. I believe the issue is with how Middleman uses Sinatra. I believe I'll need to write a small extension to tell Sinatra to serve the index.php file as the directory index. As far as Sinatra goes, I believe your answer is what I was looking for, but it just doesn't work with Middleman. – jevets Feb 08 '13 at 20:22