Class: Docit::UI::ScalarRenderer

Inherits:
BaseRenderer show all
Defined in:
lib/docit/ui/scalar_renderer.rb

Instance Attribute Summary

Attributes inherited from BaseRenderer

#nav_paths, #spec_url, #title

Instance Method Summary collapse

Methods inherited from BaseRenderer

#initialize

Constructor Details

This class inherits a constructor from Docit::UI::BaseRenderer

Instance Method Details

#renderObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/docit/ui/scalar_renderer.rb', line 6

def render
  <<~HTML
    <!DOCTYPE html>
    <html lang="en">
    <head>
      <meta charset="UTF-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <title>#{title}</title>
      <style>
        body { margin: 0; }
      </style>
    </head>
    <body>
      #{nav_bar(active: :scalar)}
      <script id="api-reference"></script>
      <script>
        document.getElementById('api-reference').dataset.configuration = JSON.stringify({
          spec: { url: #{spec_url_json} },
          theme: "elysiajs",
          showSidebar: true,
          hideDownloadButton: false,
          hideModels: false,
          searchHotKey: "k"
        })
      </script>
      <script src="https://cdn.jsdelivr.net/npm/@scalar/api-reference"></script>
    </body>
    </html>
  HTML
end