Class: Coradoc::Output::HtmlStatic

Inherits:
Object
  • Object
show all
Defined in:
lib/coradoc/html/output.rb

Overview

Static HTML output processor

Generates static HTML documents from CoreModel using the classic rendering approach without JavaScript frameworks.

Examples:

Using the processor directly

html = Coradoc::Output::HtmlStatic.processor_execute({ "doc.html" => document }, {})

Using through Output module

result = Coradoc::Output.process(document, format: :html_static)

Class Method Summary collapse

Class Method Details

.processor_execute(input, options = {}) ⇒ Hash<String, String>

Process documents to static HTML

Parameters:

  • input (Hash<String, Object>)

    mapping of filenames to documents

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

    processing options

Returns:

  • (Hash<String, String>)

    mapping of filenames to HTML output



37
38
39
40
41
42
43
44
# File 'lib/coradoc/html/output.rb', line 37

def processor_execute(input, options = {})
  result = {}
  input.each do |filename, document|
    html = Coradoc::Html::Static.convert(document, options)
    result[filename] = html
  end
  result
end

.processor_idSymbol

Processor identifier for registration

Returns:

  • (Symbol)

    the processor ID



22
23
24
# File 'lib/coradoc/html/output.rb', line 22

def processor_id
  :html_static
end

.processor_match?(filename) ⇒ Boolean

Check if this processor matches a given filename

Parameters:

  • filename (String)

    the filename to check

Returns:

  • (Boolean)

    true if this processor handles the file type



29
30
31
# File 'lib/coradoc/html/output.rb', line 29

def processor_match?(filename)
  %w[.html .htm].any? { |ext| filename.downcase.end_with?(ext) }
end