The membership operators are used to validate the membership of a value. These operators are used to find out whether a value is a member of a sequence. The result of operation returns a Boolean value.

List of Blogger Membership Operators

Operator Meaning Default syntax
in Found in Operand in [ARRAY]
Operand in ( EXPRESSION )
contains Include [ARRAY] contains Operand
EXPRESSION contains operand
Functional Syntax Operand operator ( Operand,Operand )
Operand operator ( Operand operator Operand )
Operand operator ( Operand operator ( Operand operator Operand ))

  • Member operators always return a Boolean value.
  • The Operand to be compared must be of the same type as the array, either String, Boolean or  Number.
  • The Operand to compare can be: An Blogger value, a dataset or the result of a Blogger Expression.
  • The operation can be nested in another operation that accepts operand type of boolean.
  • When ARRAY is a dataset of String, each must be wrapped with Double Quote: "STRING" and separeated by comma: "STRING","STRING".

Blogger Membership Operator Examples

Operator "[IN]"
<b:eval expr='"Foo" in ["Foo","Bar","Baz"]'/>
The result of the operation will be: true since the string Foo is in the array.
Operator "[CONTAINS]"
<b:eval expr='["Foo","Bar","Baz"] contains "Foo"'/>
The result will be: true since the array contains the string Foo. The result can be false if the dataset does not contain Foo.
Operator "[CONTAINS]" with "[EXPRESSION]"
<b:if cond='data:post.body contains "Foo"'>
  <!-- item -->
The output will be displayed if a word "Foo" is found inside post body.
Nesting in a logical operation
<b:eval expr='data:posts.size in [7,20,50] and data:view.isMultipleItems'/>
The operation result will be true if the current page contains 7 or 20 or 50 posts and the current page is a multi-posts page.
Nesting in a Lambda operation
<b:eval expr='data:posts count (p => p.labels any (l => contains "Foo"))'/>
The operation will count a total number of label name contains "Foo" in the current page view.
Nesting in a ternary operation
<b:eval expr=' in ["Foo","Bar"] ? "Welcome to Label Foo" : "Welcome to Label Bar"'/>
If current page view is Label page Foo, "Welcome to Label Foo" will be shown, and if the current label page is Bar, "Welcome to Label Bar" will be displayed.

Other operators

Share This

Creative Commons License
Blogger Book is licensed under a Creative Commons Attribution-NonCommercial 3.0 Unported License.