Place this in a file called subtemplate.rb
:
subs = { 'Info1' => "Hello", 'Info2' => 'World' }
STDIN.each do |line|
puts line.gsub(/\w+/) { |m| subs[m] }
end
Run from the command line:
ruby subtemplate.rb < template.txt > output.txt
where template.txt
contains the template file. Then output.txt
is
|Hello|World|||||||||
|||||||||||