MCPcopy Create free account
hub / github.com/EasyIME/PIME / _Expression

Class _Expression

python/python3/tornado/template.py:654–674  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

652
653
654class _Expression(_Node):
655 def __init__(self, expression: str, line: int, raw: bool = False) -> None:
656 self.expression = expression
657 self.line = line
658 self.raw = raw
659
660 def generate(self, writer: "_CodeWriter") -> None:
661 writer.write_line("_tt_tmp = %s" % self.expression, self.line)
662 writer.write_line(
663 "if isinstance(_tt_tmp, _tt_string_types):" " _tt_tmp = _tt_utf8(_tt_tmp)",
664 self.line,
665 )
666 writer.write_line("else: _tt_tmp = _tt_utf8(str(_tt_tmp))", self.line)
667 if not self.raw and writer.current_template.autoescape is not None:
668 # In python3 functions like xhtml_escape return unicode,
669 # so we have to convert to utf8 again.
670 writer.write_line(
671 "_tt_tmp = _tt_utf8(%s(_tt_tmp))" % writer.current_template.autoescape,
672 self.line,
673 )
674 writer.write_line("_tt_append(_tt_tmp)", self.line)
675
676
677class _Module(_Expression):

Callers 1

_parseFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected