Syntax logic suggestions

Posted by Anna on Programmers See other posts from Programmers or by Anna
Published on 2012-03-29T14:01:40Z Indexed on 2012/03/29 17:41 UTC
Read the original article Hit count: 349

Filed under:

This syntax will be used inside HTML attributes. Here are a few examples of what I have so far:

<input name="a" conditions="!b, c" />
<input name="b" />
<input name="c" />

This will make input "a" do something if b is not checked and c is checked (b and c are assumed to be checkboxes if they don't have a :value defined)


<input name="a" conditions="!b:foo|bar, c:foo" />
<input name="b" />
<input name="c" />

This will make input "a" do something if bdoesn't have foo or bar values, and if c has the foo value.


<input name="a" conditions="!b:EMPTY" />
<input name="b" />

Makes input "a" do something if b has a value assigned.


So, essentially , acts as logical AND, : as equals (=), ! as NOT, and | as OR. The | (OR) is only needed between values (at least I think so), and AND is not needed between values for obvious reasons :)

EMPTY means empty value, like <input value="" />

Do you have any suggestions on improving this syntax, like making it more human friendly? For example I think the "EMPTY" keyword is not really appropriate and should be replaced with a character, but I don't know which one to choose.

© Programmers or respective owner

Related posts about syntax