Class: Coradoc::Output::HtmlSpa

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

Overview

SPA (Single Page Application) HTML output processor

Generates modern Vue.js + Tailwind CSS HTML documents from CoreModel.

Examples:

Using the processor directly

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

Using through Output module

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

Class Method Summary collapse

Class Method Details

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

Process documents to SPA 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 SPA HTML output



77
78
79
80
81
82
83
84
# File 'lib/coradoc/html/output.rb', line 77

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

.processor_idSymbol

Processor identifier for registration

Returns:

  • (Symbol)

    the processor ID



62
63
64
# File 'lib/coradoc/html/output.rb', line 62

def processor_id
  :html_spa
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



69
70
71
# File 'lib/coradoc/html/output.rb', line 69

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