Get declared variable in single.php to work in comments.php without re-declaring it [closed]

The comments_template() only accepts two parameters: $file (string) and $separate_comments (Boolean). So, it does not have a way to pass an arbitrary variable as a parameter.

The two methods I generally use are:

  1. Globalize the variable
  2. Wrap the variable inside a function that returns the data you want, and then call it wherever you need it.