Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions lib/pretty-js.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -1490,6 +1501,7 @@
SHEBANG: tokenCopyAndNewline,
SINGLE_LINE_COMMENT: tokenSingleLineComment,
STRING_LITERAL: tokenString,
TEMPLATE_STRING: tokenTemplateString,
WHITESPACE: tokenSkip // Other rules manage all whitespace
};

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "*"
},
Expand Down
1 change: 1 addition & 0 deletions test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
`hello ${person}`;
4 changes: 4 additions & 0 deletions tests/fixtures/string-interpolation.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"input": "`this is a ${test}`",
"output": "`this is a ${test}`"
}