It is currently Sun Jan 29, 2023 3:22 pm

Blogger membership Operator

Blogger membership Operator

Post: #1

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 -->
</b:if>

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 => l.name 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='data:view.search.label 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.

Login

|

Who is online

In total there are 2 users online :: 0 registered, 0 hidden and 2 guests (based on users active over the past 5 minutes)
Most users ever online was 239 on Mon Dec 26, 2022 4:40 am

Statistics

Total posts 4 • Total topics 3 • Total members 1 • Our newest member admin