Skip to content

Commit 662a144

Browse files
committed
restore strings->replaceVariable
1 parent f7a1c03 commit 662a144

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

src/core/util/strings.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,8 @@ export function splitContent(content, font, wrapWidth, textWidth) {
144144

145145
// const contentExpRe = /\{([\w_]+)\}/g;
146146
// export const CONTENT_EXPRE = /{([^}.]+)}/;
147-
export let CONTENT_EXPRE = /{([\u0000-\u0019\u0021-\uFFFF]+)}/g;
147+
// export const CONTENT_EXPRE = /{([\u0000-\u0019\u0021-\uFFFF]+)}/g;
148+
export const CONTENT_EXPRE = /\{([\w_]+)\}/g;
148149

149150
/**
150151
* Replace variables wrapped by square brackets ({foo}) with actual values in props.

test/core/UtilSpec.js

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,23 @@ describe('Util', function () {
2020
expect(r).to.eql(' is not .');
2121
});
2222

23-
it('replace variables with unicode name', function () {
24-
var str = 'Be {🙂}, not be {😢}.';
25-
var r = maptalks.StringUtil.replaceVariable(str, {'🙂': 'happy', '😢': 'sad'});
26-
expect(r).to.eql('Be happy, not be sad.');
27-
});
23+
// it('replace variables with unicode name', function () {
24+
// var str = 'Be {🙂}, not be {😢}.';
25+
// var r = maptalks.StringUtil.replaceVariable(str, {'🙂': 'happy', '😢': 'sad'});
26+
// expect(r).to.eql('Be happy, not be sad.');
27+
// });
28+
29+
// it('replace variables with chinese properties', function () {
30+
// var str = 'Be {心情0}, not be {心情1}.';
31+
// var r = maptalks.StringUtil.replaceVariable(str, {'心情0': 'happy', '心情1': 'sad'});
32+
// expect(r).to.eql('Be happy, not be sad.');
33+
// });
34+
35+
// it('replace variables with chinese properties', function () {
36+
// var str = 'hello {属性+d_1}.';
37+
// var r = maptalks.StringUtil.replaceVariable(str, {'属性': 'world'});
38+
// expect(r).to.eql('hello');
39+
// });
2840
});
2941

3042
it('sign', function () {

0 commit comments

Comments
 (0)