Format the given string as a JS string literal.. Args: string: The string to format. Returns: The formatted string.
(string: str)
| 177 | |
| 178 | |
| 179 | def format_string(string: str) -> str: |
| 180 | """Format the given string as a JS string literal.. |
| 181 | |
| 182 | Args: |
| 183 | string: The string to format. |
| 184 | |
| 185 | Returns: |
| 186 | The formatted string. |
| 187 | """ |
| 188 | # Escape backticks. |
| 189 | string = string.replace(r"\`", "`") |
| 190 | string = string.replace("`", r"\`") |
| 191 | |
| 192 | # Wrap the string so it looks like {`string`}. |
| 193 | string = wrap(string, "`") |
| 194 | string = wrap(string, "{") |
| 195 | |
| 196 | return string |
| 197 | |
| 198 | |
| 199 | def format_var(var: Var) -> str: |
no test coverage detected