In that case, you might find it useful to know you can access Dataview the same way.
You can also set up Templater class files, and include all that boilerplate in the constructor:
class main {
constructor() {
this.dv = app.plugins.plugins.dataview.api
this.tp = app.plugins.plugins['templater-obsidian'].templater.current_functions_object
}
someFunction() {
return this.tp.file.title
}
async anotherfunction() {
return 'foo'
}
}
module.exports = main
Then access them from another Templater file with:
<%*
// Include the class
const yourClass = new tp.user.classFile()
// Execute a function
yourClass.someFunction()
%>