Allow dashes in template placeholders + tests
This commit is contained in:
parent
b60e18d5c6
commit
37254587be
@ -211,6 +211,7 @@ describe('Util', function () {
|
||||
|
||||
expect(str).to.eql('Hello Vlad and Dave!');
|
||||
});
|
||||
|
||||
it('does not modify text without a token variable', function () {
|
||||
expect(L.Util.template('foo', {})).to.eql('foo');
|
||||
});
|
||||
@ -226,6 +227,11 @@ describe('Util', function () {
|
||||
L.Util.template(undefined, {foo: 'bar'});
|
||||
}).to.throwError();
|
||||
});
|
||||
|
||||
it('allows underscores and dashes in placeholders', function () {
|
||||
expect(L.Util.template('{nice_stuff}', {'nice_stuff': 'foo'})).to.eql('foo');
|
||||
expect(L.Util.template('{-y}', {'-y': 1})).to.eql('1');
|
||||
});
|
||||
});
|
||||
|
||||
describe('#isArray', function () {
|
||||
|
@ -141,7 +141,7 @@ L.Util = {
|
||||
});
|
||||
},
|
||||
|
||||
templateRe: /\{ *([\w_]+) *\}/g,
|
||||
templateRe: /\{ *([\w_\-]+) *\}/g,
|
||||
|
||||
isArray: Array.isArray || function (obj) {
|
||||
return (Object.prototype.toString.call(obj) === '[object Array]');
|
||||
|
Loading…
Reference in New Issue
Block a user