forked from external/yambar
Implement conditions on tag
A condition is formed by: <tag> <op> <value> <tag> is the normal yambar tag. <op> is one of '==', '!=', '<', '<=', '>', or '>='. <value> is what you wish to compare it to. 'boolean' tags must be used directly. They falsehood is matched with '~': <tag> ~<tag> Finally, to match an empty string, one must use ' "" ': <tag> <op> ""
This commit is contained in:
parent
4496d82cfb
commit
2b103b7acd
11 changed files with 416 additions and 75 deletions
|
@ -208,7 +208,37 @@ content:
|
|||
# MAP
|
||||
|
||||
This particle maps the values of a specific tag to different
|
||||
particles. In addition to explicit tag values, you can also specify a
|
||||
particles based on conditions. A condition takes the form of:
|
||||
|
||||
<tag> <operation> <value>
|
||||
|
||||
Where <tag> is the tag you would like to map, <operation> is one of:
|
||||
|
||||
[- ==
|
||||
:- !=
|
||||
:- >=
|
||||
:- >
|
||||
:- <=
|
||||
:- <
|
||||
|
||||
and <value> is the value you would like to compare it to. Conditions
|
||||
may be chained together using either '&&' or '||':
|
||||
|
||||
<condition1> && <condition2>
|
||||
|
||||
You may surround the *whole expression* with parenthesis to make it
|
||||
more readable:
|
||||
|
||||
(<condition1> && <condition2>)
|
||||
|
||||
Note that "nested" conditions are *NOT* supported. That is, something
|
||||
like (<condition1> && (<condition2> || <condition3>)) will *NOT* work.
|
||||
|
||||
Furthermore, *conditions are evaluated with a strcmp*. This means
|
||||
some odd behaviour may arise if prefixes (such as zeroes) are added
|
||||
to numerical constants.
|
||||
|
||||
In addition to explicit tag values, you can also specify a
|
||||
default/fallback particle.
|
||||
|
||||
## CONFIGURATION
|
||||
|
@ -217,34 +247,29 @@ default/fallback particle.
|
|||
:[ *Type*
|
||||
:[ *Req*
|
||||
:[ *Description*
|
||||
| tag
|
||||
: string
|
||||
: yes
|
||||
: The tag (name of) which values should be mapped
|
||||
| values
|
||||
| conditions
|
||||
: associative array
|
||||
: yes
|
||||
: An associative array of tag values mapped to particles
|
||||
: An associative array of conditions (see above) mapped to particles
|
||||
| default
|
||||
: particle
|
||||
: no
|
||||
: Default particle to use, when tag's value does not match any of the
|
||||
mapped values.
|
||||
: Default particle to use, none of the conditions are true
|
||||
|
||||
## EXAMPLES
|
||||
|
||||
```
|
||||
content:
|
||||
map:
|
||||
tag: tag_name
|
||||
default:
|
||||
string:
|
||||
text: this is the default particle; the tag's value is now {tag_name}
|
||||
values:
|
||||
one_value:
|
||||
# Note, below, how the parenthesis are optional
|
||||
conditions:
|
||||
(tag == one_value):
|
||||
string:
|
||||
text: tag's value is now one_value
|
||||
another_value:
|
||||
tag == another_value:
|
||||
string:
|
||||
text: tag's value is now another_value
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue