Class: Hyde::Page::Html

Inherits:
Object
  • Object
show all
Includes:
W3CValidators
Defined in:
lib/hyde-page-html.rb,
lib/hyde-page-html.rb

Constant Summary collapse

VERSION =
"0.1.0"
@@config =
{
  "enable" => true,
  "validate" => true,
  "validator_uri" => nil,
  "beautify" => true,
  "minify" => true
}

Instance Method Summary collapse

Constructor Details

#initialize(page, cache) ⇒ Html

Returns a new instance of Html.



53
54
55
56
57
58
59
60
61
62
63
# File 'lib/hyde-page-html.rb', line 53

def initialize(page, cache)
  @page = page
  @site = page.site
  @cache = cache
  @config = fetch_config

  @validator = W3CValidators::NuValidator.new({
    # running with docker locally docker run -it --rm -p 8888:8888 ghcr.io/validator/validator:latest
    validator_uri: @config.fetch('validator_uri')
  })
end

Instance Method Details

#runObject



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/hyde-page-html.rb', line 65

def run
  return @page.output unless @config.fetch('enable')

  output = @page.output

  if @config.fetch('validate')
    validate
  end

  if @config.fetch('beautify')
    output = beautify
  end

  if @config.fetch('minify')
    output = minify
  end

  @page.output = output
end