WebDNA Contexts

A WebDNA context encloses a block of text and requires a beginning and ending tag. Like HTML enclosing tags, the ending WebDNA context tag is specified with the name of the context preceded by a forward slash "/". Like WebDNA tags, contexts are enclosed in square brackets rather than angle brackets. In a programming sense, the context implies a scope.

The following is a WebDNA context example:

Daily Information
[showif [date]=01/01/2009]
Today is the first day of 2009
[/showif]

The [showif] context shows or hides portions of text based upon a comparison included in the beginning context tag. Because [showif] is executed on the server, if the comparison is not true, then the text between the [showif] tags is not displayed at all.

You can include WebDNA tags within context tags. When this occurs, the innermost tag is interpreted before the outer tags are interpreted. Thus rather than strictly comparing the raw text "[date]" to "01/01/2009" (which is always false), the value for the WebDNA tag [date] is inserted before the comparison is evaluated. If the date equals "01/01/2009" then the expression is true and all the text between the beginning and ending [showif] tags is displayed on the web page, and sent to the browser. The context tags themselves are discarded once they have done their job of interpreting the WebDNA code into text.

Thus the output sent to the browser on 01/01/2009 would be:

Daily Information
Today is the first day of 2009

As indicated earlier, WebDNA allows nested contexts by enclosing a context within a context. This lets you create very complex behaviors with combinations of WebDNA tags. Like HTML enclosing tags, they must be nested. WebDNA Team

DOWNLOAD WEBDNA NOW!

Top Articles:

Fun with WebDNA Videos

These videos are created by Dan Strong...

WebDNA: an incredibly flexible scripting language and database system

WebDNA is an easy-to-learn server-side scripting language specifically designed for creating feature rich...

WebDNA Tags and Contexts

A WebDNA tag exists on its own just like an HTML tag...

What is WebDNA?

WebDNA is a scripting language application that connects with web servers for the purpose of adding dynamic and database-driven qualities to web sites...

WSC Products

Welcome to WebDNA 8...

Related Readings:

WebDNA Contexts

A WebDNA context encloses a block of text and requires a beginning and ending tag...

A short description of how WebDNA processes your web pages

WebDNA is a very powerful Server Side interpreter; it includes an unlimited...