mirror of
https://gitlab.com/gitlab-org/gitlab-foss.git
synced 2025-07-25 16:03:48 +00:00
31 lines
663 B
Ruby
31 lines
663 B
Ruby
# frozen_string_literal: true
|
|
|
|
require_relative 'helper'
|
|
|
|
module Tooling
|
|
module DastVariables
|
|
module Docs
|
|
class Renderer
|
|
include Tooling::DastVariables::Docs::Helper
|
|
|
|
attr_reader :schema
|
|
|
|
def initialize(output_file:, template:)
|
|
@output_file = output_file
|
|
@template = template
|
|
@layout = Haml::Engine.new(File.read(template))
|
|
end
|
|
|
|
def contents
|
|
# Render and remove an extra trailing new line
|
|
@contents ||= @layout.render(self).sub!(/\n(?=\Z)/, '')
|
|
end
|
|
|
|
def write
|
|
File.write(@output_file, contents)
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|