mirror of
https://github.com/lloeki/tilt-pdf.git
synced 2025-12-06 10:34:41 +01:00
correctly handle multiple css files
This commit is contained in:
parent
931a4496f7
commit
b80e340342
1 changed files with 7 additions and 4 deletions
|
|
@ -13,7 +13,7 @@ module Tilt
|
||||||
def evaluate(scope, locals, &block)
|
def evaluate(scope, locals, &block)
|
||||||
main = render_html(main_html_file, scope, locals, &block)
|
main = render_html(main_html_file, scope, locals, &block)
|
||||||
|
|
||||||
render_css(*css_files) do |*css|
|
render_css(*css_files) do |css|
|
||||||
kit = PDFKit.new(main, pdfkit_options)
|
kit = PDFKit.new(main, pdfkit_options)
|
||||||
css.each { |f| kit.stylesheets << f }
|
css.each { |f| kit.stylesheets << f }
|
||||||
@output = kit.to_pdf
|
@output = kit.to_pdf
|
||||||
|
|
@ -75,19 +75,22 @@ module Tilt
|
||||||
def render_css(*files)
|
def render_css(*files)
|
||||||
tmps = []
|
tmps = []
|
||||||
|
|
||||||
files.each do |file|
|
css = files.map do |file|
|
||||||
case file
|
case file
|
||||||
when /.*\.css$/
|
when /.*\.css$/
|
||||||
yield file
|
file
|
||||||
else
|
else
|
||||||
tmp = Tempfile.new(File.basename(file))
|
tmp = Tempfile.new(File.basename(file))
|
||||||
tmps << tmp
|
tmps << tmp
|
||||||
css = Tilt.new(file).render
|
css = Tilt.new(file).render
|
||||||
tmp.write(css)
|
tmp.write(css)
|
||||||
tmp.close
|
tmp.close
|
||||||
yield tmp.path
|
|
||||||
|
tmp.path
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
yield css
|
||||||
ensure
|
ensure
|
||||||
tmps.each { |tmp| tmp.close! }
|
tmps.each { |tmp| tmp.close! }
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue