Closed amcgregor closed 8 years ago
The following example produces strangeness:
: def template : if False Hi.
This generates the following code (pre-1.0):
def template(*, _escape=_escape, _bless=_bless, _args=_args): if False: _buffer = [] __w, __ws = _buffer.extend, _buffer.append __ws(' Hi.\n') yield "".join(_buffer)
The _buffer allocation being itself conditional results in problems. Lame, naive solution: have all template functions call ensure_buffer immediately.
_buffer
ensure_buffer
Resolved by ensuring the buffer is immediately recreated upon flush, rather than relying on deferred reconstruction.
The following example produces strangeness:
This generates the following code (pre-1.0):
The
_buffer
allocation being itself conditional results in problems. Lame, naive solution: have all template functions callensure_buffer
immediately.