Class: Nanoc::WeasyPrint::Filter

Inherits:
Filter
  • Object
show all
Includes:
FileUtils, Spawn
Defined in:
lib/nanoc/weasyprint/filter.rb

Constant Summary

Constants included from Spawn

Spawn::Error

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Spawn

#spawn

Class Method Details

.default_argvArray<String>

Returns The default command line options forwarded to weasyprint.

Returns:

  • (Array<String>)

    The default command line options forwarded to weasyprint.



14
15
16
# File 'lib/nanoc/weasyprint/filter.rb', line 14

def self.default_argv
  @default_argv ||= []
end

Instance Method Details

#run(content, options = {}) ⇒ void

This method returns an undefined value.

Parameters:

  • content (String)

    HTML contnet.

  • options (Hash) (defaults to: {})

    Filter options.



26
27
28
29
30
# File 'lib/nanoc/weasyprint/filter.rb', line 26

def run(content, options = {})
  spawn "weasyprint",
        [*default_argv, *(options[:argv] || []), temporary_file(content).path, output_filename],
        log: File.join(tmpdir, "weasyprint.log")
end