referator/test/render.rb
2023-09-30 00:41:45 +04:00

17 lines
407 B
Ruby
Executable file

#!/usr/bin/env ruby
# frozen_string_literal: true
require 'erb'
require 'json'
require 'pathname'
def template(filename)
pathname = Pathname.new(__dir__).join(filename).expand_path.freeze
ERB.new(pathname.read, trim_mode: '-').tap do |erb|
erb.filename = pathname.to_s.freeze
end.freeze
end
puts template("#{ARGV[0]}.#{ARGV[1]}.erb").result_with_hash(
notes: JSON.parse($stdin.read),
).strip