The Now Platform® Washington DC release is live. Watch now!
I warned you yesterday that I'd have more to say about the evaluate tag, and today I'm here to deliver on that threatpromise.
Isaac doesn't look exactly thrilled at that prospect. But he should be!
The evaluate tag has a few special features, all worth understanding. They're the kinds of things that you won't always need, but when you need 'em you'll be glad they're there...
First up: the var attribute. Here's a sample that I'll explain in a second:
<?xml version="1.0" encoding="utf-8"?>
<j:jelly>
<g:evaluate>
var random = 1 + (Math.floor((new Date().getTime() ${AMP} 0xffff) * Math.random()) % 6);
random;
</g:evaluate>
Your rolled: ${jvar_die}
</j:jelly>
<?xml version="1.0" encoding="utf-8"?>
<j:jelly>
<g:evaluate/>
Your rolled: ${jvar_die}
</j:jelly>
<?xml version="1.0" encoding="utf-8"?>
<j:jelly>
<g:evaluate/>
<g:evaluate/>
Your rolled: ${jvar_die}
</j:jelly>
<?xml version="1.0" encoding="utf-8"?>
<j:jelly>
<g:evaluate>
var dice = new Packages.java.util.ArrayList();
for (var i = 0; 10 > i; i++) {
var die = 1 + (Math.floor((new Date().getTime() ${AMP} 0xffff) * Math.random()) % 6);
dice.add(die.toFixed(0));
}
dice;
</g:evaluate>
Your rolled:
<j:foreach>${jvar_die} </j:foreach>
</j:jelly>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.