text/template: using comparison operators ("eq", "gt", etc.) on non-existent variable causes the template to stop outputting but with no error - correct behaviour?

84 views
Skip to first unread message

Jonathan Ingram

unread,
Feb 10, 2014, 6:40:59 PM2/10/14
to golan...@googlegroups.com
This looks like a bug to me, but I wanted to get some feedback first.

Take a look at this example: http://play.golang.org/p/QZq2QBVIJj

In my example, it seems that the "eq" function fails because it comes across a variable that is not passed to the template (well, I guess it's technically a key that does not exist in the map passed to the template).

The template stops outputting, but there doesn't appear to be any error or panic, so any idea what's going on here?

Note: my example is slimmed down. Imagine this in a HTML template - this literally causes the remaining template HTML to disappear so you've essentially got all these open tags where the template dies.

Jesse McNelis

unread,
Feb 10, 2014, 6:44:35 PM2/10/14
to Jonathan Ingram, golang-nuts
The error is returned, you've just ignored it.


--
=====================
http://jessta.id.au

Jonathan Ingram

unread,
Feb 10, 2014, 6:47:33 PM2/10/14
to golan...@googlegroups.com, Jonathan Ingram, jes...@jessta.id.au
Wow :S

Thanks Jesse :)
Reply all
Reply to author
Forward
0 new messages