MCPcopy Create free account
hub / github.com/webpy/webpy / DefwithNode

Class DefwithNode

web/template.py:546–567  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

544
545
546class DefwithNode:
547 def __init__(self, defwith, suite):
548 if defwith:
549 self.defwith = defwith.replace("with", "__template__") + ":"
550 # offset 4 lines. for encoding, _lineoffset_, loop and self.
551 self.defwith += "\n _lineoffset_ = -4"
552 else:
553 self.defwith = "def __template__():"
554 # offset 4 lines for encoding, __template__, _lineoffset_, loop and self.
555 self.defwith += "\n _lineoffset_ = -5"
556
557 self.defwith += "\n loop = ForLoop()"
558 self.defwith += "\n self = TemplateResult(); extend_ = self.extend"
559 self.suite = suite
560 self.end = "\n return self"
561
562 def emit(self, indent):
563 encoding = "# coding: utf-8\n"
564 return encoding + self.defwith + self.suite.emit(indent + INDENT) + self.end
565
566 def __repr__(self):
567 return f"<defwith: {self.defwith}, {self.suite}>"
568
569
570class TextNode:

Callers 1

parseMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected