how to make variable accessible in requirejs callback function

I have a piece of code with requirejs

var path = this.formatPath(path);
require([path], function (template) {

//....code here

});

And I’d like to print the path inside the requirejs callback function.

Something like this

var path = this.formatPath(path);
require([path], function (template) {

//console.log(path)

});

However because the callback function is in a different scope, I can’t access it.

How do I pass the path variable in the callback function?