Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ES6 Template literal backticks #30

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
15 changes: 13 additions & 2 deletions core/js_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ def getConsoleStr(self):
def getConsoleSingleQuotes(self):
return settings().get('js').get('single_quotes', False)

def getConsoleBackTicks(self):
return settings().get('js').get('back_ticks', False)

def getSemicolonSetting(self):
return settings().get('js').get('semicolon', False)

Expand Down Expand Up @@ -110,11 +113,14 @@ def find_next_line(self, view, region):
def get_wrapper(self, view, var, indent_str, insert_before):
consoleStr = self.getConsoleStr()
single_quotes = self.getConsoleSingleQuotes()
back_ticks = self.getConsoleBackTicks()
insertSemicolon = self.getSemicolonSetting()
consoleFunc = self.getConsoleFunc()
separator = ", "

if single_quotes:
if back_ticks:
text = var.replace("`", "\\`")
elif single_quotes:
text = var.replace("'", "\\'")
else:
text = var.replace('"', '\\"')
Expand All @@ -135,7 +141,12 @@ def get_wrapper(self, view, var, indent_str, insert_before):

tmpl = indent_str if insert_before else ("\n" + indent_str)

quotes = "'" if single_quotes else "\""
if back_ticks:
quotes = "`"
elif single_quotes:
quotes = "'"
else:
quotes = "\""
a = ("{4}({0}{1}{0}{2}{3}){5}").format(quotes, t, separator, v, ".".join(consoleFunc), semicolon)
a = a.format(title=text, variable=var)

Expand Down