Allow to use arobase in variables

fix #1028
This commit is contained in:
Yohan Boniface 2023-07-19 08:25:31 +02:00
parent 1be7950237
commit 56586125a4
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(