|
Definition of Whitebeam XML Tags
|
rb:eval
Evaluate a JavaScript expression BodyThe body of this tag is always empty. Attributes
Attribute |
Required |
Description | expr | required |
JavaScript expression to evaluate - with an optional replacement attribute name.
|
Remarks Use of this tag will evaluate the JavaScript expression contained in the 'expr'
attribute and replace the value of the tag with the value of the expression.
The expression can contain any valid JavaScript, including entire programmes
although in practice it is best to reserve this tag for simple JavaScript expressions
and to use the <rb:script...> tag for more
complex scripts. It is recommended that the bulk of the Whitebeam Script for a Pattern Page
be included at the head of the page and then accessed through <rb:eval...>
tags or through the equivalent attribute (rb:eval). This is by no means required
but experience has shown that intermingling lots of server side and client side
JavaScript can become very confusing! <BODY>
<H1>Customer Information</H1>
<TABLE>
<TR>
<TD>Name</TD>
<TD><rb:eval
expr="rb.user.name()"></TD>
</TR>
<TR>
<TD>DOB</TD>
<TD><rb:eval expr="rb.user.dob()"
/></TD>
</TR>
</TABLE>
...
Processing by the Whitebeam presentation engine (given an appropriate
ROM view) would generate the following
HTML:
<BODY>
<H1>Customer Information</H1>
<TABLE>
<TR>
<TD>Name</TD>
<TD>Fred
Bloggs</TD>
</TR>
<TR>
<TD>DOB</TD>
<TD>10th March
1972</TD>
</TR>
</TABLE>
...
The 'expr' attribute can contain any valid JavaScript including code that
generates output via side-effects (The main example being
rb.page.write) The creates
a potential conflict about how to generate the output from this tag. Should
the implementation use the output generated from the side-effect or
from the result of the expression. To resolve this conflict the Whitebeam
Presentation Engine employs the following rules (in order of precedence): If the result of the expression is not void then the value is converted
to a string and becomes the result of executing the tag. If the result of the expression is void and there has been output
generated by the script, for example by 'rb.page.write' then this output
is used to replace the <rb:eval...> tag in the generated page. If neither of the above is true then there is no output and the
<rb:eval...> tag is removed from the output stream. This is useful
in the case where the Pattern Page wishes to invoke some template
functionality but does not wish to generate output.
Note. To force
an expression to evaluate to 'void' in JavaScript the void keyword
may be used as follows: <rb:eval expr="void (rb.template.read())">
When executed this tag generates no output, regardless of whether
the call to rb.template.read returns a value. |
|
(loadtime : 10ms) |