Skip to content

Commit

Permalink
Clear output and render "nothing" when a view returns the empty string
Browse files Browse the repository at this point in the history
Closes #100.
  • Loading branch information
meowgorithm committed Jun 2, 2021
1 parent 1f773e8 commit 6547773
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions standard_renderer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down

0 comments on commit 6547773

Please sign in to comment.