This is actually a mistake, but there is a workaround. Replace the def function with this modified code:
myFunc = function(arg1, arg2) { firstString = "This is a regular string: #{arg1}. No problem there."; secondString = << This is a heredoc with a beesting: #{arg2}. Problem! >>; "#{secondString}"; };
Note that the last statement (return value) is a quoted list. This forces you to allow any exits inside the heredoc, and it works.
The problem arises because KRL late binds beesting substitutions before javascript is executed, but there is an error in generating a closure, which leads to the fact that the variable is not available. Forcing permission with a cited list solves this problem.
source share