Templater
Templater copied to clipboard
Conflict between Templater и Smart-Typography
One of the features of the Smart-Typography plugin is automatically turning standard double quotes into curly double quotes ("" → ““). This is a very subtle change that is hard to notice, and I didn't even know about this until I discovered my issue (I initially downloaded the plugin just for em-dashes).
At some point I started setting up the plugin Templater and encountered an issue where, when creating simple templates (for example, just inserting the creation date <% tp.file.creation_date(“D MMMM YYYY“)%>
), while processing the template, Templater crashed with a parsing error
Templater Error: Template parsing error, aborting.
Bad template syntax
and an error message in the console that is not interpretable
Invalid or unexpected token
===========================
var tR='',__l,__lP,include=E.include.bind(E),includeFile=E.includeFile.bind(E)
function layout(p,d){__l=p;__lP=d}
const _prs = [];
_prs.push(tp.file.creation_date(“D MMMM YYYY“));
tR+='rJ2KqXzxQg'
tR+='\n\n'
const _rst = await Promise.all(_prs);
tR = tR.replace(/rJ2KqXzxQg/g, () => _rst.shift());
if(__l)tR=await includeFile(__l,Object.assign(tp,{body:tR},__lP))
if(cb){cb(null,tR)} return tR
After some digging around, I finally discovered that the issue was in Templater not being able to parse the curly quotes, and everything was, of course, fixed by using the standard quotes.
Preventive measures?
- The error message is very hard to interpret. At least it should be able to better pinpoint the lines where the error lies? Instead of giving lots of code that I don't recognize at all and get no useful info from.
- Maybe something can be done specifically against cases like this? For example, inform the user their Templater code blocks include unparseable characters.