Skip to content

Commit 13f59ea

Browse files
committed
workaround issue 209
1 parent 8914e1c commit 13f59ea

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

parser_expression.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,13 @@ func (expr *relationalExpression) Evaluate(ctx *ExecutionContext) (*Value, *Erro
201201
case "!=", "<>":
202202
return AsValue(!v1.EqualValueTo(v2)), nil
203203
case "in":
204+
val, ok := expr.expr1.(*simpleExpression)
205+
if ok && val.negate {
206+
t1, err := val.term1.Evaluate(ctx)
207+
if err == nil {
208+
return AsValue(!v2.Contains(t1)), nil
209+
}
210+
}
204211
return AsValue(v2.Contains(v1)), nil
205212
default:
206213
return nil, ctx.Error(fmt.Sprintf("unimplemented: %s", expr.opToken.Val), expr.opToken)

template_tests/if.tpl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
{% if !simple.uint %}false{% else %}!simple.uint{% endif %}
77
{% if !simple.float %}false{% else %}!simple.float{% endif %}
88
{% if "Text" in complex.post %}text field in complex.post{% endif %}
9+
Hello string {% if not "Hello" in complex.post.Text %}is not{% else %}is{% endif %} in complex.post.Text
10+
World string {% if not "World" in complex.post.Text %}is not{% else %}is{% endif %} in complex.post.Text
911
{% if 5 in simple.intmap %}5 in simple.intmap{% endif %}
1012
{% if !0.0 %}!0.0{% endif %}
1113
{% if !0 %}!0{% endif %}

template_tests/if.tpl.out

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ float != 0.0
66
!simple.uint
77
!simple.float
88
text field in complex.post
9+
Hello string is in complex.post.Text
10+
World string is not in complex.post.Text
911
5 in simple.intmap
1012
!0.0
1113
!0

0 commit comments

Comments
 (0)