diff --git a/lib/pretty-js.js b/lib/pretty-js.js index 6ff4fd9..c219a6d 100644 --- a/lib/pretty-js.js +++ b/lib/pretty-js.js @@ -1438,6 +1438,17 @@ result.addSpace(); } + /** + * Processes a template string and does not process quotes. + * + * @param {prettyJs~Result} result + * @param {complexionJs~ComplexionJsToken} token + */ + function tokenTemplateString(result, token) { + result.addFragment('STRING', token.content); + result.addSpace(); + } + // Initialize a new tokenizer with the default options tokenizer = new Complexion(); complexionJs(tokenizer); @@ -1490,6 +1501,7 @@ SHEBANG: tokenCopyAndNewline, SINGLE_LINE_COMMENT: tokenSingleLineComment, STRING_LITERAL: tokenString, + TEMPLATE_STRING: tokenTemplateString, WHITESPACE: tokenSkip // Other rules manage all whitespace }; diff --git a/package.json b/package.json index 54c948a..f9de38c 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ ], "dependencies": { "complexion": "~0.1.3", - "complexion-js": "~0.1.5", + "complexion-js": "git+https://github.com/tests-always-included/complexion-js.git#feature/add_template_strings", "option-parser": "*", "process-files": "*" }, diff --git a/test.js b/test.js new file mode 100644 index 0000000..b255284 --- /dev/null +++ b/test.js @@ -0,0 +1 @@ +`hello ${person}`; diff --git a/tests/fixtures/string-interpolation.json b/tests/fixtures/string-interpolation.json new file mode 100644 index 0000000..eda4e2a --- /dev/null +++ b/tests/fixtures/string-interpolation.json @@ -0,0 +1,4 @@ +{ + "input": "`this is a ${test}`", + "output": "`this is a ${test}`" +}