Using single curly braces as delimiters doesn't work
nfantone opened this issue · 1 comments
nfantone commented
I was messing around with the new delimiters
option released in 2.0.0-beta.1
and found out that setting {
and }
as start
and end
delimiters respectively, breaks in some cases.
const dot = require('dot')
const tmpl = dot.template('{?merchant}/{=merchant}{?}/{=version}/{=product}', {
argName: ['merchant', 'version', 'product'],
delimiters: { start: '{', end: '}' },
})
tmpl({ product: 'cookie', version: '1.0.0', merchant: '243' }) 🐛
// Could not create a template function: let out='';if(merchant)';out+='/'+(merchant);out+='out+='/'+(version)+'/'+(product);return out;
Uncaught SyntaxError: Unexpected identifier
If I don't use conditionals in my template string, the rendering works fine.
const tmpl = dot.template('/{=merchant}/{=version}/{=product}', {
argName: ['merchant', 'version', 'product'],
delimiters: { start: '{', end: '}' },
})
tmpl({ product: 'cookie', version: '1.0.0', merchant: '243' }) ✅
// '/243/1.0.0/cookie'
Other delimiters that I've tried, such as [
and ]
, seem to work fine in all scenarios, though.
bojanvidanovic commented
Yep, confirming this, using custom delimiters will break conditionals.