mirror of
https://github.com/lloeki/tilt-pdf.git
synced 2025-12-08 03:24:40 +01:00
Compare commits
No commits in common. "master" and "v0.9.0" have entirely different histories.
4 changed files with 39 additions and 6 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
PATH
|
PATH
|
||||||
remote: .
|
remote: .
|
||||||
specs:
|
specs:
|
||||||
tilt-pdf (0.10.0)
|
tilt-pdf (0.1.2)
|
||||||
pdfkit (~> 0.5.4)
|
pdfkit (~> 0.5.4)
|
||||||
tilt (~> 1.4.1)
|
tilt (~> 1.4.1)
|
||||||
|
|
||||||
|
|
|
||||||
17
README.mdown
17
README.mdown
|
|
@ -29,8 +29,8 @@ A `foo` template is currently threefold:
|
||||||
document.
|
document.
|
||||||
- `foo.css`: this stylesheet can be written in any template language you need
|
- `foo.css`: this stylesheet can be written in any template language you need
|
||||||
(such as Sass or Less), and the Tilt template resolution system via extension
|
(such as Sass or Less), and the Tilt template resolution system via extension
|
||||||
chaining will apply. Tilt will pass the block to be yielded to this
|
chaining will apply. Tilt will *not* pass the block to be yielded to this
|
||||||
template, so you'd rather not `yield` if you fancy using `.css.erb`.
|
template.
|
||||||
|
|
||||||
The three files must currently be stored in the *same* directory.
|
The three files must currently be stored in the *same* directory.
|
||||||
|
|
||||||
|
|
@ -84,5 +84,14 @@ as based from the rpdf file.
|
||||||
|
|
||||||
## Rails and ActionView integration
|
## Rails and ActionView integration
|
||||||
|
|
||||||
Starting with 0.10, this functionality has been split into its own gem. Use
|
Require `tilt/pdf/rails` if you want to set up and register `tilt-pdf` as an
|
||||||
[Tilt::PDF::Rails](https://github.com/lloeki/tilt-pdf-rails)
|
ActionView template handler. You can do it in an initializer, or straight from
|
||||||
|
the Gemfile:
|
||||||
|
|
||||||
|
```ruby
|
||||||
|
gem 'tilt-pdf', require: 'tilt/pdf/rails'
|
||||||
|
```
|
||||||
|
|
||||||
|
Put your three template files *together* in the relevant `app/views/foo` view
|
||||||
|
directory, or use absolute paths using application/engine root. Work is in
|
||||||
|
progress to enable better integration with Rails file layout.
|
||||||
|
|
|
||||||
24
lib/tilt/pdf/rails.rb
Normal file
24
lib/tilt/pdf/rails.rb
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
require 'tilt-pdf'
|
||||||
|
|
||||||
|
module ActionView
|
||||||
|
class Template
|
||||||
|
module Handlers
|
||||||
|
class PDFTemplate
|
||||||
|
class_attribute :default_format
|
||||||
|
self.default_format = :pdf
|
||||||
|
|
||||||
|
def call(template)
|
||||||
|
"Tilt.new('#{template.identifier}').render(self)"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
register_template_handler :rpdf, Handlers::PDFTemplate.new
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
module Tilt::PDFTemplate::Rails
|
||||||
|
class Railtie < ::Rails::Railtie
|
||||||
|
config.app_generators.template_engine :rpdf
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
module Tilt
|
module Tilt
|
||||||
module PDF
|
module PDF
|
||||||
VERSION = '0.10.0'
|
VERSION = '0.9.0'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue