reasoncorp / dossier

Ruby-based report generation/presentation Rails engine.
MIT License
385 stars 79 forks source link

Custom Layout #30

Closed timscott closed 10 years ago

timscott commented 10 years ago

Is there a way to use a custom layout for views? My intent is to link a custom stylesheet. Maybe there is another way to do that and otherwise add things to the document head?

timscott commented 10 years ago

By the way, I tried just adding /app/views/dossier/layouts/application.html.haml without success.

adamhunter commented 10 years ago

Hey @timscott,

There are a couple ways you could handle this. Personally, if you just want a custom stylesheet, I would add a yield :stylesheets call in your existing layout. You can then have a custom report view that has content_for :stylesheets, stylesheet_link_tag('report') (content_for can alternatively take a block).

The second option would be setting the dossier report controller layout in a to_prepare block in application.rb. For example in application.rb config.to_prepare { Dossier::ReportsController.layout 'report' }

Let me know if you have any questions on either of these options and thanks for using dossier!

adamhunter commented 10 years ago

This example from the devise wiki explains the same thing with their rails engine, just with a few more examples. https://github.com/plataformatec/devise/wiki/How-To:-Create-custom-layouts#define-in-config

timscott commented 10 years ago

Perfect. Thanks.