Previous Chapter | Next Chapter | Up | Next Section | Contents

The dtml-var Tag


The dtml- var tag is used to perform simple variable substitutions. A number of attributes are provided to control how text is to be inserted and formatted. The attributes are summarized in table 15.

dtml-var tag attributes

Attribute name

Needs an argument?

Description

name

yes

Insert the name of the variable.

expr

yes

Insert an expression that evaluates a value.

fmt

yes

Specify a data format, which may be a special, custom, or C-style format.

null

yes

Specify a string to be substituted for null values.

lower

no

Convert all upper-case letters to lower case

upper

no

Convert all lower-case letters to upper case.

capitalize

no

Convert the first character of the inserted to upper case.

spacify

no

Convert underscores in the inserted value to spaces.

thousands_commas

no

In a value containing all numbers, insert commas every three digits to the left of a decimal point. For example, "12000 widgets" becomes "12,000 widgets".

html_quote

no

Convert characters that have special meaning in HTML to HTML character entities.

url_quote

no

Convert characters that have special meaning in URLs to HTML character entities using decimal values.

url_quote_plus

no

Converts a single space character in URLs to the plus sign "+".

sql_quote

no

Convert single quotation mark to a pair of single quotation marks. This is needed to safely include values in Standard Query Language (SQL) strings.

newline_to_br

no

Convert new-line characters, carriage-return characters, and new-line-carriage-return character combinations to new-line characters followed by HTML break tags.

size

yes

Truncate the value to the given size.

etc

yes

Provide a string to be added to truncated text to indicate that truncation has occurred. The default value is "...".

missing

no

Provide a value to be used if the variable is missing, rather than raising an KeyError. Used without an argument, it will provide an empty string.

Previous Chapter | Next Chapter | Up | Next Section | Contents

SUBSECTIONS