github.com/coveo/gotemplate@v2.7.7+incompatible/docs/doc_test/conditionals.razor (about)

     1  {% include navigation.html %}
     2  {% raw %}
     3  # Conditionals in gotemplate
     4  
     5  ```go
     6  {{- $is_true_1 := $.true }}
     7  {{- $is_true_2 := $.true }}
     8  {{- $is_false_1 := $.false }}
     9  {{- $is_false_2 := $.false }}
    10  {{- $false_string := "false" }}
    11  
    12  {{- if $is_true_1 }}
    13      TestTrue
    14  {{- end }}
    15  
    16  {{- if $is_false_1 }}
    17      TestFalse
    18  {{- end }}
    19  
    20  {{- if and $is_true_1 $is_true_2 }}
    21      TestTrueAndTrue
    22  {{- end }}
    23  
    24  {{- if and $is_true_1 $is_false_1 }}
    25      TestTrueAndFalse
    26  {{- end }}
    27  
    28  {{- if or $is_true_1 $is_false_1 }}
    29      TestTrueOrFalse
    30  {{- end }}
    31  
    32  {{- if $false_string }}
    33      FalseStringIsTrue
    34  {{- end }}
    35  ```
    36  
    37  will give:
    38  
    39  ```go
    40      TestTrue
    41      TestTrueAndTrue
    42      TestTrueOrFalse
    43      FalseStringIsTrue
    44  ```
    45  
    46  {% endraw %}