Simplify utils.javascript.assemble
This commit is contained in:
parent
4046615b37
commit
1307d8e9a2
@ -19,8 +19,6 @@
|
|||||||
|
|
||||||
"""Utilities related to javascript interaction."""
|
"""Utilities related to javascript interaction."""
|
||||||
|
|
||||||
import textwrap
|
|
||||||
|
|
||||||
from qutebrowser.utils import utils
|
from qutebrowser.utils import utils
|
||||||
|
|
||||||
|
|
||||||
@ -65,12 +63,7 @@ def _convert_js_arg(arg):
|
|||||||
|
|
||||||
def assemble(module, function, *args):
|
def assemble(module, function, *args):
|
||||||
"""Assemble a javascript file and a function call."""
|
"""Assemble a javascript file and a function call."""
|
||||||
code = textwrap.dedent("""
|
js_args = ', '.join(_convert_js_arg(arg) for arg in args)
|
||||||
"use strict";
|
code = '"use strict";\nwindow._qutebrowser.{}.{}({});'.format(
|
||||||
window._qutebrowser.{module}.{function}({args});
|
module, function, js_args)
|
||||||
""").format(
|
|
||||||
module=module,
|
|
||||||
function=function,
|
|
||||||
args=', '.join(_convert_js_arg(arg) for arg in args),
|
|
||||||
)
|
|
||||||
return code
|
return code
|
||||||
|
Loading…
Reference in New Issue
Block a user