Merge pull request #1217 from umap-project/arobase-in-variable

Allow to use arobase in variables
This commit is contained in:
Yohan Boniface 2023-07-19 15:42:22 +02:00 committed by GitHub
commit 04a36556bd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

View file

@ -174,7 +174,7 @@ L.Util.greedyTemplate = (str, data, ignore) => {
}
return str.replace(
/\{ *([\w_\:\.\|]+)(?:\|("[^"]*"))? *\}/g,
/\{ *([\w_\:\.\|@]+)(?:\|("[^"]*"))? *\}/g,
(str, key, staticFallback) => {
const vars = key.split('|')
let value

View file

@ -236,6 +236,15 @@ describe('L.Util', function () {
)
})
it('should accept arobase', function () {
assert.equal(
L.Util.greedyTemplate('A phrase with a {@variable}.', {
'@variable': 'value',
}),
'A phrase with a value.'
)
})
it('should replace even with ignore if key is found', function () {
assert.equal(
L.Util.greedyTemplate(