错误:展示模板中的“用于比较的无效类型”

After creating multple endpoints customizing footer.html, I end up with this error for not apparent this don't effect the functionally of the application, just annoying me. Tried:

  revel run revel_app or dev

Revel Template Execution Error

: executing "footer.html" at : error calling eq: invalid type for comparison.

  {{if eq .RunMode "dev"}}

  {{template "debug.html" .}}

  {{end}}
 </body>

</html>

The error you see arises when one of the arguments to eq is either undefined in the current context or is not of a "basic type" (see the last paragraph of this section)

So assuming that footer.html is a "pratial" template that is associated with other templates which invoke the footer template using the template action you need to ensure that the context passed in to the template invocation contains the .RunMode value and that the value is of a basic type.

While this question seems to be answered there is plenty missing. First the question is incomplete... WHAT IS THE ERROR? My guess us that the .RunMode is missing when the template parser/executor was run. There are not best practices for golang templates, however, this is a common problem when overloading templates and not maintaining a dictionary of variables.

One strategy I tend to deploy is:

{{if eq (or .RunMode "default") "dev"}}

This way if .RunMode is NOT assigned a value (nil exception) or an empty string then the eq uses the "default" value instead. Think of this as a shorthand like in 'C'

This is an exaggerated example.

a := runmode!=null?runmode:default