Range operator can be used only in operator that has table view, mostly used in blogger inside <b:loop> tag. There is three operator, [limit], [offset] and [to].
Not like the other two, the operator [to] can only be used in <b:loop> tag, and he cannot be associated with other operator or combined with other operator in the expression. We can say he is loner and must be alone.
Blogger Range Operator List
Operator | Meaning | Default syntax |
---|---|---|
limit |
Limit the output by x * number | array take number |
take |
array limit number | |
Skip |
Skip x* number of the output | array skip number |
offset |
array offset number | |
to |
Define number x* to x* | number to number |
Blogger Range Operator [LIMIT] aka [TAKE]
The operatorstake
or limit
allow us define a maximum limit table view sets of an array.
Example with String dataset
<b:loop values='["foo","bar","baz"] limit 2' var='item'> <data:item/> </b:loop>
Example with data:posts
<b:loop values='data:posts limit 2' var='item'> <a expr:href='data:post.url'><data:post.title/></a> </b:loop>
Blogger Range Operator [OFFSET] aka [SKIP]
Operatorsskip
or offset
will give a statement to start the display from the specified statement.
Example with String dataset
<b:loop values='["foo","bar","baz"] offset 2' var='item'> <data:item/> </b:loop>
Example with blogger data
<b:loop values='data:posts skip 2' var='item'> <a expr:href='data:post.url'><data:post.title/></a> </b:loop>
Blogger Range operator [TO]
This operatorto
creates an array of numbers form x* to x*, and only accept number as operand.
Example Creating Range
<b:loop values='3 to 5' var='item'> <data:item/> </b:loop>As stated above, this operator is a loner. Lets say, from the 7 post set as maximum number post set in the Blog 1 Widget Settings, we want to take only post 3, 4 and 5. We cannot write like the other two operators, which we can inject on the tail 'data:post 3 to 5'. See the workaround from the example below
Example to take only post 3, 4 and 5
<b:loop values='2 to 4' var='range'> <b:loop index='number' values='data:posts' var='post'> <b:if cond='data:number == data:range'> <a expr:href='data:post.url'><data:post.title/></a> </b:if> </b:loop> </b:loop>