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

Method write_javascript

Lib/pagebot/elements/page.py:652–687  ·  view source on GitHub ↗

Builds the JS body. There are 4 option (all not including the ... ): 1 As path a HTML file, containing the string between ... , including the tags. 2 Constructed from info context, page attributes and styles. 3 As accumulated i

(self, view)

Source from the content-addressed store, hash-verified

650 b._html()
651
652 def write_javascript(self, view):
653 """Builds the JS body. There are 4 option (all not including the
654 <script>...</script>):
655
656 1 As path a HTML file, containing the string between
657 <script>...</script>, including the tags.
658 2 Constructed from info context, page attributes and styles.
659 3 As accumulated inside builders (from b.getJs())
660 4 As html/javascript string (view.jsCode and/or self.jsCode are defined
661 as not None)
662 """
663 context = view.context
664 b = context.b
665
666 for jsUrls in (view.jsUrls, self.jsUrls):
667 if jsUrls is not None:
668 for jsUrl in jsUrls:
669 b.script(type="text/javascript", src=jsUrl)
670
671 for jsPaths in (view.jsPaths, self.jsPaths):
672 if jsPaths:
673 for jsPath in jsPaths:
674 b.script(type="text/javascript")
675 b.addHtml(jsPath)
676 b._script()
677
678 if b.hasJs():
679 b.script(type="text/javascript")
680 b.addHtml(b.getJs())
681 b._script()
682
683 for jsCode in (view.jsCode, self.jsCode):
684 if jsCode is not None:
685 b.script(type="text/javascript")
686 b.addHtml(jsCode)
687 b._script()
688
689if __name__ == "__main__":
690 import doctest

Callers 1

write_bodyMethod · 0.95

Calls 5

scriptMethod · 0.80
addHtmlMethod · 0.80
_scriptMethod · 0.80
hasJsMethod · 0.80
getJsMethod · 0.80

Tested by

no test coverage detected