mirror of
https://github.com/optilude/xlsx-template.git
synced 2026-07-02 08:27:39 +08:00
fix wrongly replacing text in shared strings
This commit is contained in:
+1
-2
@@ -770,8 +770,7 @@ module.exports = (function() {
|
||||
} else {
|
||||
var newString = string.replace(placeholder.placeholder, self.stringify(substitution));
|
||||
cell.attrib.t = "s";
|
||||
self.replaceString(string, newString);
|
||||
return newString;
|
||||
return self.insertCellValue(cell, newString)
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@@ -638,8 +638,8 @@ describe("Helpers", function() {
|
||||
t.addSharedString(string);
|
||||
buster.expect(t.substituteScalar(col, string, placeholder, substitution)).toEqual("foo: bar");
|
||||
buster.expect(col.attrib.t).toEqual("s");
|
||||
buster.expect(val.text).toEqual("0");
|
||||
buster.expect(t.sharedStrings).toEqual(["foo: bar"]);
|
||||
buster.expect(val.text).toEqual("1");
|
||||
buster.expect(t.sharedStrings).toEqual(["foo: ${foo}", "foo: bar"]);
|
||||
});
|
||||
|
||||
it("can substitute parts of strings with booleans", function() {
|
||||
@@ -666,8 +666,8 @@ describe("Helpers", function() {
|
||||
t.addSharedString(string);
|
||||
buster.expect(t.substituteScalar(col, string, placeholder, substitution)).toEqual("foo: 0");
|
||||
buster.expect(col.attrib.t).toEqual("s");
|
||||
buster.expect(val.text).toEqual("0");
|
||||
buster.expect(t.sharedStrings).toEqual(["foo: 0"]);
|
||||
buster.expect(val.text).toEqual("1");
|
||||
buster.expect(t.sharedStrings).toEqual(["foo: ${foo}", "foo: 0"]);
|
||||
});
|
||||
|
||||
it("can substitute parts of strings with numbers", function() {
|
||||
@@ -694,8 +694,8 @@ describe("Helpers", function() {
|
||||
t.addSharedString(string);
|
||||
buster.expect(t.substituteScalar(col, string, placeholder, substitution)).toEqual("foo: 10");
|
||||
buster.expect(col.attrib.t).toEqual("s");
|
||||
buster.expect(val.text).toEqual("0");
|
||||
buster.expect(t.sharedStrings).toEqual(["foo: 10"]);
|
||||
buster.expect(val.text).toEqual("1");
|
||||
buster.expect(t.sharedStrings).toEqual(["foo: ${foo}", "foo: 10"]);
|
||||
});
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user