by nthWave Web Works Elements Docs

Introduction
Overview
Installation
Initiating the Process
Small Site Tutorial
Elements In Depth...
    Script Demos
    Sample XML Processor
  •In-line Math
    Site Content in Single File
Platform Specific...
Glossary
History
Support

Downloads



Support the
good work:

support email

Examples : Inline Math.

Tired of calculating the table and cell widths of complicated tables? Let the code do the math! By defining all widths as elements, you can do the math inline in the template.

for example:

#tableWidth 360
#td1Width 90
#spacer src="{pathToTop}images/spacer.gif" height="36" border="1"

<img {spacer} width="{tableWidth}">
<img {spacer} width="{td1Width}">
<img {spacer} width="{int(tableWidth) - int(td1Width) -2}">

(subtract 2 from the last spacer to accont for the image borders)
results in:

<img {spacer} width="360">
<img {spacer} width="90">
<img {spacer} width="268">

for code in a table that displays like this:

A more advanced example could use a script at the top of the page to turn all the width elements into integers so that the in-line scripts didn't need to do the conversion. Something like:

def convertToInt():
    elementNames = ['tableWidth', 'td1Width']
    for elem in elementNames:
        page.elements[elem] = int(page.elements[elem])
    return ''


Elements is brought to you by nthWave Web Works
this page was built on Fri May 2 15:31:28 2003