Pajk/apipie-rails — pull request #52 by ronen (2012-08-24 01:01:17+00:00)
Title: Added config.layout for doc pages

hi again,

i found i wanted to integrate the apipie pages into my application's layout. so i added another configuration field to set the layout:

```
Apipie.configure do |config|
...
config.layout = 'api'
...
end
```

of course it was then incumbent on me to ensure that i included the appropriate css and javascript to make the interaction work. so i made a wrapper layout for the api docs, which then calls the main application layout. that is, i have layouts/api.html.haml:

- content_for :head do
- %w[bundled/bootstrap.min.css application.css bundled/prettify.css bundled/bootstrap-responsive.min.css ].each do |file|
%link{type: "text/css", rel: "stylesheet", href: Apipie.full_url("stylesheets/#{file}")}
- content_for :tail do
- %w[ bundled/bootstrap-collapse.js bundled/prettify.js apipie.js ].each do |file|
%script{type: "text/javascript", src: Apipie.full_url("javascripts/#{file}")}
=render :template => "layouts/application"

and layouts/application.html.haml has yield :head and yield :tail in the appropriate places.

i cribbed all that stuff from apipie's layout -- but it could be nice instead to bundle them into some convenient helpers. i didn't want to do that without feedback from you first, though.

so anyway i don't know if you want to pull this as is, or use it as a springboard for some other approach, or ignore it entirely :) but i figured i'd at least show it to you.

thanks,
-ronen