How to Build It
If you type the Water expression datetime.today, into the source code pane and press Execute, the browser pane shows the following:
2002-4-23
The datetime.today will return a date object representing the current date. If you right-click in the browser pane and choose View Source it will show the following without any HTML tags:
2002-4-23
To embed today's date in an HTML tag, type the following:
<HTML> Today is <datetime.today/> </HTML>
The Water code returns the correct result, but the value has no name in which to identify the expression. To name an object in Water, use set:
<set the_date= <HTML> Today is <datetime.today/> </HTML> />
When this program is executed on a Water server, it creates a variable named the_date that holds an instance of the HTML object.
To return the value of the the_date variable, just reference the variable by name as follows:
the_date
In Water, the value of the last expression is returned. The program below will return the HTML page:
<set the_date= <HTML> Today is <datetime.today/> </HTML> /> the_date
When the program is loaded onto the server named "water.waterlang.org" the the_date variable gets defined. The value of the variable can be returned using the URL:
http://water.waterlang.org/the_date
it returns
<HTML> Today is 2002-4-23 </HTML>
This works because everything in the path section of the URL is executed as Water code. The string, the_date, is executed on the server and the HTML object is printed for display.