Files
gitlab-foss/tooling/dast_variables/docs/renderer.rb
2025-03-05 09:13:50 +00:00

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