setOutputMode(mode)

Changes what syntax is used when generating elements. Valid modes are:

PHPTAL::XHTML

In this mode (which is default) PHPTAL will output XHTML in a way that is backwards-compatible with HTML browsers.

  • Empty elements will be forced to use self-closing form (<img/>, <link/>), and non-empty elements will always have closing tag.

    Warnung

    XHTML output mode changes <link> element in way that is incompatible with RSS. Use XML output mode to generate RSS feeds or use Atom.

  • Boolean attribtes (checked, selected, etc.) will always have value required by the XHTML specification (it simplifies use of tal:attributes).

  • <![CDATA[ blocks will be added or removed automatically and will use special escaping syntax that is safe in both XML and HTML.

    Tipp

    If you're always sending XHTML as application/xhtml+xml, then it's better to use XML output mode.

PHPTAL::HTML5

This mode generates documents that have best compatibility with text/html parsing in current web browsers, but are not XML.

PHPTAL will change DOCTYPEs to <!DOCTYPE html>. Namespace declarations, name prefixes, explicit CDATA sections and other HTML-incompatible constructs will be ommited.

Anmerkung

This mode is not a "tag soup". PHPTAL will close all elements properly and quote attributes when it's necesary. Output will be properly formatted HTML 5, and fully backwards-compatible with current HTML 4 browsers.

PHPTAL::XML

This mode outputs "pure" XML without compatibility with text/html parsing. Use this mode when generating feeds, SVG, MathML, RDF and other XML files.