diff --git a/htag/tag.py b/htag/tag.py index 11b924b..66cfe91 100644 --- a/htag/tag.py +++ b/htag/tag.py @@ -578,10 +578,14 @@ def _getAllJs(self) -> list: ll=[] # auto-declare js methods for exposed's python methods + autodeclares=[] for method_name in set(dir(self)) - TAG_KEYWORDS: if hasattr( getattr(self,method_name) ,"_autoExposeClientSide_"): logger.debug("expose python method '%s' as js caller in %s",method_name,repr(self)) - ll.append( "self.%s = function(_) {%s};" % (method_name,BaseCaller(self,method_name,[b"...arguments"],{})) ) + autodeclares.append( "self.%s = function(_) {%s}" % (method_name,BaseCaller(self,method_name,[b"...arguments"],{})) ) + + if autodeclares: + ll.append( self._genIIFEScript( ";".join(autodeclares) ) ) #IIFE ! if self.js: logger.debug("Init Script (.js) found in %s --> '%s'",repr(self),self.js)