## Class THtmlWriter

Description

Implements interfaces:

- ITextWriter

THtmlWriter class

THtmlWriter is a writer that renders valid XHTML outputs. It provides functions to render tags, their attributes and stylesheet fields. Attribute and stylesheet values will be automatically HTML-encoded if they require so. For example, the 'value' attribute in an input tag will be encoded.

A common usage of THtmlWriter is as the following sequence:

      $writer->addAttribute($name1,$value1);
      $writer->addAttribute($name2,$value2);
      $writer->renderBeginTag($tagName);
      // ... render contents enclosed within the tag here
        $writer->renderEndTag();

Make sure each invocation of renderBeginTag is accompanied with a renderEndTag and they are properly nested, like nesting tags in HTML and XHTML.

- since: 3.0
- version: $Revision: $ $Date: $
- author: Qiang Xue <qiang.xue@gmail.com>

Located in /Web/UI/THtmlWriter.php (line 39)

    TComponent
       |
       --TApplicationComponent
          |
          --THtmlWriter

Method Summary
THtmlWriter __construct (ITextWriter $writer)
void addAttribute (string $name, string $value)
void addAttributes (array $attrs)
void addStyleAttribute (string $name, string $value)
void addStyleAttributes (array $attrs)
void flush ()
void removeAttribute (string $name)
void removeStyleAttribute (string $name)
void renderBeginTag (string $tagName)
void renderEndTag ()
void write (string $str)
void writeBreak ()
void writeLine ([string $str = ''])
Methods
Constructor __construct (line 108)

Constructor.

- access: public

THtmlWriter __construct (ITextWriter $writer)

- ITextWriter $writer: a writer that THtmlWriter will pass its rendering result to

addAttribute (line 128)

Adds an attribute to be rendered.

- access: public

void addAttribute (string $name, string $value)

- string $name: name of the attribute
- string $value: value of the attribute

addAttributes (line 117)

Adds a list of attributes to be rendered.

- access: public

void addAttributes (array $attrs)

- array $attrs: list of attributes to be rendered

addStyleAttribute (line 157)

Adds a stylesheet attribute to be rendered

- access: public

void addStyleAttribute (string $name, string $value)

- string $name: stylesheet attribute name
- string $value: stylesheet attribute value

addStyleAttributes (line 146)

Adds a list of stylesheet attributes to be rendered.

- access: public

void addStyleAttributes (array $attrs)

- array $attrs: list of stylesheet attributes to be rendered

flush (line 175)

Flushes the rendering result.

This will invoke the underlying writer's flush method.

- access: public

void flush ()
removeAttribute (line 137)

Removes the named attribute from rendering

- access: public

void removeAttribute (string $name)

- string $name: name of the attribute to be removed

removeStyleAttribute (line 166)

Removes the named stylesheet attribute from rendering

- access: public

void removeStyleAttribute (string $name)

- string $name: name of the stylesheet attribute to be removed

renderBeginTag (line 210)

Renders the openning tag.

- access: public

void renderBeginTag (string $tagName)

- string $tagName: tag name

renderEndTag (line 240)

Renders the closing tag.

- access: public

void renderEndTag ()
write (line 184)

Renders a string.

- access: public

void write (string $str)

- string $str: string to be rendered

writeBreak (line 201)

Renders an HTML break.

- access: public

void writeBreak ()
writeLine (line 193)

Renders a string and appends a newline to it.

- access: public

void writeLine ([string $str = ''])

- string $str: string to be rendered

#### Inherited Methods

Inherited From TApplicationComponent

> TApplicationComponent::getApplication()
> TApplicationComponent::getRequest()
> TApplicationComponent::getResponse()
> TApplicationComponent::getService()
> TApplicationComponent::getSession()
> TApplicationComponent::getUser()
> TApplicationComponent::publishAsset()
> TApplicationComponent::publishFilePath()

Inherited From TComponent

> TComponent::attachEventHandler()
> TComponent::canGetProperty()
> TComponent::canSetProperty()
> TComponent::detachEventHandler()
> TComponent::evaluateExpression()
> TComponent::evaluateStatements()
> TComponent::getEventHandlers()
> TComponent::getSubProperty()
> TComponent::hasEvent()
> TComponent::hasEventHandler()
> TComponent::hasProperty()
> TComponent::raiseEvent()
> TComponent::setSubProperty()
> TComponent::__get()
> TComponent::__set()

Documentation generated on Sun, 04 Jun 2006 18:59:29 -0400 by phpDocumentor 1.3.0RC4