MCPcopy Create free account
hub / github.com/PageBot/PageBot / addJs

Method addJs

Lib/pagebot/contexts/htmlcontext/htmlbuilder.py:360–368  ·  view source on GitHub ↗

Add js to output, if name is None or optional name is not already in self._jsNames. Otherwise skip export, to avoid JS chunks to double in the output. This is used to avoid doubling JS chunks if multiple elements of the same type are in one page.

(self, js, name=None)

Source from the content-addressed store, hash-verified

358 self._jsNames = set() # Keep optional js chunck names, so avoid double output.
359
360 def addJs(self, js, name=None):
361 """Add js to output, if name is None or optional name is not already in self._jsNames.
362 Otherwise skip export, to avoid JS chunks to double in the output. This is used
363 to avoid doubling JS chunks if multiple elements of the same type are in one page."""
364 assert isinstance(js, str), ('Added Javascript should be of type str "%s"' % js)
365 if name is None or not name in self._jsNames:
366 self._jsOut.append(js)
367 if name is not None:
368 self._jsNames.add(name)
369
370 def hasJs(self):
371 return len(self._jsOut)

Callers 15

importJsMethod · 0.95
build_htmlMethod · 0.80
build_htmlMethod · 0.80
build_htmlMethod · 0.80
build_htmlMethod · 0.80
build_htmlMethod · 0.80
build_htmlMethod · 0.80
build_htmlMethod · 0.80
build_htmlMethod · 0.80
build_htmlMethod · 0.80
build_htmlMethod · 0.80
build_htmlMethod · 0.80

Calls 2

addMethod · 0.80
appendMethod · 0.45

Tested by

no test coverage detected