Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using single curly braces as delimiters doesn't work #313

Open
nfantone opened this issue Feb 21, 2022 · 1 comment
Open

Using single curly braces as delimiters doesn't work #313

nfantone opened this issue Feb 21, 2022 · 1 comment

Comments

@nfantone
Copy link

nfantone commented Feb 21, 2022

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.

@nfantone nfantone changed the title Using single curly brace as delimiter doesn't work Using single curly braces as delimiters doesn't work Feb 21, 2022
@bojanvidanovic
Copy link

Yep, confirming this, using custom delimiters will break conditionals.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants