The problem
I have a template that says: take the url in the clipboard, and if it contains the word x, then call template x; if it contains y call template y. The template works for everything but “Letterboxd” (a movie site), pretty much the only site I use it for. I use it every day, at least 10-20 times per day. I was using it all day today until about 3 hours ago when out of the blue it threw an error.
The error
Console says:
Templater Error: Template parsing error, aborting. Cannot read properties of null (reading 'href')
I’m not familiar enough with how the console works to see where else I should look for details.
About the Template:
It works for everything (youtube, imdb, wikipedia) but stopped for Letterboxd 3 hours ago. (I had a Windows Update in the queue, so I updated just in case it was causeing the issue. Made no difference).
<%*
// https://github.com/SilentVoid13/Templater/discussions/846
let clipboard = await tp.system.clipboard();
clipboard = clipboard.trim(); // remove whitespace from both ends
let urlExpression = /^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)?/gmi;
let urlRegex = new RegExp(urlExpression);
if (clipboard.includes("/www.youtube.com/")) {
// Insert YouTube template
tR += await tp.file.include("[[youtube template]]");
} else if (clipboard.includes("/www.imdb.com/")) {
tR += await tp.file.include("[[imdb template]]");
} else if (clipboard.includes("/letterboxd.com/")) {
tR += await tp.file.include("[[LB template]]");
} else if (clipboard.includes("wikipedia.org/")) {
tR += await tp.file.include("[[wikipedia template]]");
} else if (clipboard.match(urlRegex)) {
tR += await tp.file.include("[[website]]");
} else {
new Notice("No link in the clipboard");
}
%>