I am using Templater to populate a template file for meeting notes with some basic data (filename, topic, date, etc.) — I also want to use part of the filename (to be exact, the last word) for a frontend element called title.
The template looks somewhat like this:
As you can see, I have defined a JS function for the title based on the function getLastWord. That JS function is looking as follows:
function getLastWord(str) {
// Split the string into an array of words
const words = str.split(' ');
// Return the last word in the array
return words.pop();
}
module.exports = getLastWord();
However, when I am trying to use the template, I continuously get the error message “Default export is not a function”.
Things I have tried
I try to simply export the function via export = getLastWord(); - that does not work as well.
I am not quite sure what I am missing here - any help is highly appreciated
Just encountered this same problem (while adding the IMdb Quickadd Macro) and the first hit of the same wording were both of your posts, both here and on reddit. I think I found the solution in the same search, provided by the indelible @Christian over on his GitHub Quickadd issue page:
Maybe you figured something out already, but perhaps this is still helpful to others.