diff options
author | Joerg Bornemann <joerg.bornemann@qt.io> | 2018-05-28 09:35:54 +0200 |
---|---|---|
committer | Joerg Bornemann <joerg.bornemann@qt.io> | 2018-06-01 12:10:05 +0000 |
commit | 1e5db01c23b7ae4e966faff870567618ad1fa5b5 (patch) | |
tree | 626d81615768a2f8bf4370cb53a8ef2c4fa19f44 /tests/auto/blackbox/testdata/choose-module-instance | |
parent | 250e6da6cb06eb7ca82fae0d98be8b4b6123cfcf (diff) |
Make the texttemplate module public
Also, adjust the syntax to be closer to ES2015's template literals.
[ChangeLog] Introduced the texttemplate module, a facility similar to
qmake's SUBSTITUTES feature.
Task-number: QBS-1050
Change-Id: Id4d45ac962d68f44a060aefafb20263d7f21ba9f
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Diffstat (limited to 'tests/auto/blackbox/testdata/choose-module-instance')
-rw-r--r-- | tests/auto/blackbox/testdata/choose-module-instance/gerbil.txt.in | 4 | ||||
-rw-r--r-- | tests/auto/blackbox/testdata/choose-module-instance/modules/texttemplate/texttemplate.qbs | 49 |
2 files changed, 2 insertions, 51 deletions
diff --git a/tests/auto/blackbox/testdata/choose-module-instance/gerbil.txt.in b/tests/auto/blackbox/testdata/choose-module-instance/gerbil.txt.in index 53b91dbcd..4722829a3 100644 --- a/tests/auto/blackbox/testdata/choose-module-instance/gerbil.txt.in +++ b/tests/auto/blackbox/testdata/choose-module-instance/gerbil.txt.in @@ -1,5 +1,5 @@ I once had a gerbil named Bobby, Who had an unusual hobby. -He $DID on a $THING, -and now -- oh my $IDOL, +He ${DID} on a ${THING}, +and now -- oh my ${IDOL}, now all that's left is a blobby. diff --git a/tests/auto/blackbox/testdata/choose-module-instance/modules/texttemplate/texttemplate.qbs b/tests/auto/blackbox/testdata/choose-module-instance/modules/texttemplate/texttemplate.qbs deleted file mode 100644 index aca755373..000000000 --- a/tests/auto/blackbox/testdata/choose-module-instance/modules/texttemplate/texttemplate.qbs +++ /dev/null @@ -1,49 +0,0 @@ -import qbs.TextFile - -Module { - property var dict: ({}) - FileTagger { - patterns: ["*.in"] - fileTags: ["texttemplate.input"] - } - Rule { - inputs: ["texttemplate.input"] - Artifact { - fileTags: ["text"] - filePath: input.completeBaseName - } - prepare: { - var cmd = new JavaScriptCommand(); - cmd.silent = true; - cmd.sourceCode = function() { - try { - var src = new TextFile(input.filePath, TextFile.ReadOnly); - var dst = new TextFile(output.filePath, TextFile.WriteOnly); - var rex = /\$([A-Z]+)/g; - while (!src.atEof()) { - rex.lastIndex = 0; - var line = src.readLine(); - while (true) { - var result = rex.exec(line); - if (!result) - break; - var replacement = input.texttemplate.dict[result[1]]; - if (replacement) { - line = line.substr(0, result.index) - + replacement - + line.substr(result.index + result[0].length); - } - } - dst.writeLine(line); - } - } finally { - if (src) - src.close(); - if (dst) - dst.close(); - } - }; - return [cmd]; - } - } -} |