From: "dsisnero (Dominic Sisneros)" Date: 2022-11-03T21:38:24+00:00 Subject: [ruby-core:110597] [Ruby master Feature#19015] Language extension by a heredoc Issue #19015 has been updated by dsisnero (Dominic Sisneros). It reminds me of javascript template literals and tagged templates. Instead of passing in bindings they pass the interpolation points and the first argument is an array containing thestring split at interpolation points, and the second is the interplation values. ``` ruby require 'cgi' def heredoc_extension_erb strs_separated_array_at, **interpolation_points result = strs_separated_array.zip(interpolation_points).each_with_object([]) do |s, v, ar| ar << s ar << v if v end result.join(" ") end name = 'ko1' html = <Hello #{name} erb ``` I could see where this could be used to provide cmd interpolation similar to julia ``` ruby files = ["/etc/password", "/Volumes/External HD/data.csv"] def heredoc_ext_cmd(strs_ar, values) # shellescape values - # if current_values is a array and curr_str ends in space and next str is nonexistant or ends in space join values with a space # #collect cmd and cmd_args result = Process.new(cmd, cmd_args) end mycmd = <Hello <%= name %> erb puts html #=>
Hello ko1
``` ## Background / considerations * Sometimes we write Ruby syntax string with `<