Hi *,

unfortunately, I don't have edit privileges for "official" wiki pages so I keep 
bugging you ;-)

I recently discovered how to change the default output format for Genshi. I 
hope 
the attached addition for the Genshi page 
(http://docs.turbogears.org/1.0/GenshiTemplating) will help others 
understanding 
some Genshi features.

Please note that the markup was not validated - probably some statements need 
to 
  be changed.

fs

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears Docs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/turbogears-docs?hl=en
-~----------~----~----~----~------~----~------~--~---


Generating other formats than HTML 
----------------------------------

By default Genshi will generate HTML output. Please note that Genshi does not
treat "XHTML" as HTML. The effect is that statements like
::
<html xmlns="http://www.w3.org/1999/xhtml";
          xmlns:py="http://genshi.edgewall.org/";
          xmlns:xi="http://www.w3.org/2001/XInclude";>
...
<br />

will be changed in the output. The resulting page which is delivered to the 
browser looks like this::
<html>
...
<br>

This behavior causes problems if you want to validate your XHTML pages. 
Fortunately, you can specify output format explicitely. One 
possibility is to do it for a single function as it was shown in 
ExposeDecorator::

@expose(template="project.templates.welcome", format='xhtml')
def welcome():
        pass
        
But using the method above, the global default would stay ``html``. To change 
the global default use TurboGears' configuration mechanism. The option 
``genshi.outputformat`` will control what the default output format is. Valid
values are ``html`` (default), ``xhtml``, ``xml``, and ``text``. You may want
to change the option ``genshi.default_doctype`` too. The valid values are
documented on the `Genshi 
page<http://genshi.edgewall.org/wiki/Documentation/plugin.html#genshi-default-doctype>`_

::
genshi.default_doctype="xhtml-transitional"
genshi.outputformat = "xhtml"

Reply via email to