Definition of Whitebeam XML Tags

Site Map
 
Home
 
Application Guide
Reference
  Installation
  Configuration
  XML Markup
    authenticate
    block
    cachecontrol
    eval
    false
    header
    include
    insertblock
    insertdebug
    macrotag
    marksession
    nomacro
    noscript
    parser
    redirect
    repeatfor
    return
    script
    if
    test
    true
    xmp
    eval
    id
    marksession
    test
  JavaScript Classes
  ROM
  Templates
  Environment
  Dev Process
  Tools
  External Links
  Example libraries
Community
Contact Whitebeam
To-Do
Download
Credits
Licence
Whitebeam Users
 
 
 

Definition of Whitebeam XML Tags

rb:block

Mark an area of XML - don't insert into the document

Body

The rb:authenticate body can contain any other XML markup.

Attributes

Attribute Required Description

rb:id

implied

If specified this attribute allows rb.page.tagtree to get a handle to the specific node.

Remarks

The block tag is used to bracket a section of Whitebeam markup. By itself the effect of the tag is to remove the block from the XML document. Whenever an <rb:block...> tag is encountered in a Pattern Page being executed - all the children of that tag are immediately skipped. No execution of those children takes place! This may seem a little strange until you understand why this can be useful.

There are two common uses of this tag - firstly it can trivially be used to 'comment out' a block of debug code within a Pattern Page.

The more interesting use is to define a proforma set of XML code and then use this to stamp out a number of instances of that code within the Pattern Page in a 'cookie cutter' kind of model. To do this you have to give the block an id, using the rb:id attribute. Once you've identified the block you can then reference it from within JavaScript using the rb.page.tagtree method. This is probably best illustrated by example:

<body>
   <!-- Define a block of XML that will display a row in
     -- the output table. The values for the row are extracted
     -- from JavaScript variables set when the block is used.
     -- This block in itself will generate no output and the
     -- JavaScript will NOT be executed.
     -->

   <rb:block rb:id="tablerow">
      <tr>
         <rb:eval expr="void (t=arr[x])"/>
         <td> <rb:eval expr="x"/> </td>
         <td> <rb:eval expr="t.toSource()"/> </td>
         <td> <a rb:eval="'href=&quot;'+t.ref+'&quot;'">link</a></td>
      </tr>
   </rb:block>
 
   <h1>Decoding form parameters.</h1>

   <!-- First of all get a JavaScript representation of the 'row' XML -->
   <rb:eval expr="var tt=rb.page.tagtree('tablerow')"/>

   <!-- Now insert a copy of the row block for each value in the
     -- JavaScript array 'arr'.
     -->
   <table border="1">
      <rb:repeatfor expr="x in arr">
         <rb:script>
            // 'regenerate' causes the XML block to be re-executed each
            // time through the loop, with different JavaScript values
            tt.regenerate();

            // Having regenerated the XML block - send it to
            // the page being build.
            rb.page.write(tt.bodytext());
         </rb:script>
      </rb:repeatfor>
   </table>

   <h1>TEST TITLE OUTPUT</h1>
</body>

There are two main things to highlight in this example. Firstly the construction of the prototype 'block' that contains the outline for a single row in a table and secondly the loop that instantiates that block a number of times to create a multi-row table.

The prototype block is contained in the <rb:block...> tag. When the Presentation Engine sees this tag it immediately skips the whole of that tags body - moving to the next tag. It there contributes NO output to the page being constructed.

The prototype block is subsequently used with the <rb:repeatfor...> tag, which loops through a set of object properties and runs the prototype once for each row.

The prototype block is executed from within JavaScript - the <rb:script...> tag as follows:

<rb:eval expr="var tt=rb.page.tagtree('tablerow')"/>

This is outside of the loop. It sets a JavaScript variable to reference the sub-tree labelled 'tablerow', the name we gave too the prototype block. The variable 'tt' is now a reference to the prototype block of XML that we want to duplicate. This variable is used within the body of the loop to access the XML subtree.

tt.regenerate();

This method causes the Presentation Engine to rerun the XML subtree identified by 'tt' - our prototype XML block. When the block is executed it is as though it were in line. As such it has access to the operational environment within the loop. So the block can access loop control variables, even though those variables did not exist at the time the block was declared.

Whitebeam release 1.3.36
(loadtime : 8ms)