8000 Using single curly braces as delimiters doesn't work · Issue #313 · olado/doT · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Using single curly braces as delimiters doesn't work #313
Open
@nfantone

Description

@nfantone

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0