Clear output and render "nothing" when a view returns the empty string

Closes #100.
This commit is contained in:
Christian Rocha 2021-06-02 13:20:30 -04:00
parent 1f773e8f20
commit 6547773a3f
1 changed files with 9 additions and 0 deletions

View File

@ -205,6 +205,15 @@ func (r *standardRenderer) write(s string) {
r.mtx.Lock()
defer r.mtx.Unlock()
r.buf.Reset()
// If an empty string was passed we should clear existing output and
// rendering nothing. Rather than introduce additional state to manage
// this, we render a single space as a simple (albeit less correct)
// solution.
if s == "" {
s = " "
}
_, _ = r.buf.WriteString(s)
}