# wt.textblock module

## Synopsis

The `wt.textblock` module provides a `TemplateCode` sub-class which helps with dynamically creating paragraphs of text.

## Usage

This class is used for creating paragraphs of HTML out of a text string. Double-newlines in the string (i.e. blank lines) are treated as paragraph separators. Single newlines are converted to `<br>` tags. Newlines of the form `\n` or `\r\n` are supported.

Example:

`<!--wt:body-->
<p>$$=paragraph$$</p>
<!--wt:/body-->`

`import jon.wt.textblock as textblock
class body(textblock.TextBlock):
def text(self):
return self.outer.article["body"]`

Note the use of the `=` literal encoding specifier, because the output is raw HTML (including `<br>` tags).

## class: TextBlock(TemplateCode)

### Public Instance Variables

#### `paragraph`

This variable is set to the HTML code for each paragraph in turn by the `main()` method.

### Public Methods

#### `text(self)`

Returns: string

This method may be overridden by subclasses. It returns a string containing the text data to be turned into HTML paragraphs. The default implementation just returns the empty string.

#### `main(self, template)`

`template`: string

This method may be overridden by subclasses. It calls `text()` to fetch the text data and splits it into paragraphs. Each paragraph in turn is converted to HTML, placed into the `paragraph` attribute, and `process()` called.

$Id: wt-textblock.html,v 1.3 2003/04/22 16:11:51 jribbens Exp $