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

Properties with underscore not working in compile mode #18

Open
ksmithut opened this issue Jan 20, 2017 · 1 comment
Open

Properties with underscore not working in compile mode #18

ksmithut opened this issue Jan 20, 2017 · 1 comment

Comments

@ksmithut
Copy link

Using version 1.0.0 on node v6.9.4:

const format = require("string-template")
const compile = require("string-template/compile")

const vars = {
  hostName: 'my.only.host.com',
  host_tenant: 'only',
  host_lane: 'prd',
  subdomain: 'my.only',
}

console.log(format('http://{hostName}-{host_tenant}-{host_lane}-{subdomain}', vars))
// Logs out "http://my.only.host.com-only-prd-my.only"

const template = compile('http://{hostName}-{host_tenant}-{host_lane}-{subdomain}')
console.log(template(vars))
// Logs out "http://my.only.host.com-{host_tenant}-{host_lane}-my.only"

Can be reproduced here: https://runkit.com/58827adb4ddfcf0014890d06/58827adb4ddfcf0014890d07

@ksmithut
Copy link
Author

ksmithut commented Jan 20, 2017

I believe this is fixed by changing this line: https://github.com/Matt-Esch/string-template/blob/master/compile.js#L4 to allow an _ in its charset, but you may want to support other valid characters in variable names such as $

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

1 participant