From 6547773a3f677c91cd261f307d7f5162973d1170 Mon Sep 17 00:00:00 2001 From: Christian Rocha Date: Wed, 2 Jun 2021 13:20:30 -0400 Subject: [PATCH] Clear output and render "nothing" when a view returns the empty string Closes #100. --- standard_renderer.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/standard_renderer.go b/standard_renderer.go index 7578524..cc5cbca 100644 --- a/standard_renderer.go +++ b/standard_renderer.go @@ -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) }