How to organize a check on the value on the tmpl page. Used gin: Example tmpl page:

Текст1 {{if .Test = 1}} Выводим этот текст {{end}} Текст2 

Here in the Test variable which is transferred to the page the figure is saved, how to check the unit is it? Because so he swears.

    1 answer 1

     {{if eq .Test 1}} Выводим этот текст {{end}} 

    See https://golang.org/pkg/text/template/ :

    There is also a set of binary comparison operators defined as functions:

     eq Returns the boolean truth of arg1 == arg2 ne Returns the boolean truth of arg1 != arg2 lt Returns the boolean truth of arg1 < arg2 le Returns the boolean truth of arg1 <= arg2 gt Returns the boolean truth of arg1 > arg2 ge Returns the boolean truth of arg1 >= arg2