#2287: No simple way to make TurboGears 2 produce HTML
-------------------------+--------------------------------------------------
 Reporter:  chrisz       |       Owner:        
     Type:  enhancement  |      Status:  new   
 Priority:  normal       |   Milestone:  2.0   
Component:  TurboGears   |     Version:  2.0rc1
 Severity:  normal       |    Keywords:  html  
-------------------------+--------------------------------------------------
 In TG 1.0, switching between HTML and XHTML output was the matter of only
 one config setting, but in TG 2.0 this has become very difficult. By
 default TG 2.0 produces XHTML (while TG 1.0 produced HTML by default) and
 there is no clean and simple way to use HTML in TG 2.0.

 Note that I'm not against using XHTML as the default, but there are many
 good reasons to produce HTML instead of XHTML, so people should at least
 be given the [http://www.htmlgoodies.com/beyond/xml/print.php/3669451
 choice].

 There are two problems:

  1. Changing the output method of the default render function (using
 Genshi) is not as straightforward as it should be (as discussed
 
[http://groups.google.com/group/turbogears/browse_thread/thread/7f65c32d4621a52e
 here]).
  2. Even if you change the default Genshi renderer, the ressource
 injection of !ToscaWidgets will still use XHTML for CSS links, because it
 uses the string.Template rendering engine with a hardcoded XHTML template
 (as discussed [http://groups.google.de/group/toscawidgets-
 discuss/browse_thread/thread/91765d109965ad2d here]).

 My current solution is to add the following code to
 `config/environment.py`:
 {{{
 # Make Genshi render HTML (instead of XHTML) by default:

 _load_environment = load_environment

 def load_environment(*args):

     _load_environment(*args)

     from genshi.output import DocType, HTMLSerializer

     render_genshi = base_config.render_functions.genshi

     def render_genshi_html(*args, **kwargs):
         return render_genshi(method='html', *args, **kwargs)

     base_config.render_functions.genshi = render_genshi_html

 # Monkey-patch ToscaWidget so that it creates a valid HMTL link tag
 # instead of a XHTML tag when injecting resources:

 from tw.api import CSSLink

 CSSLink.template = CSSLink.template.replace('/>', '>')
 }}}
 This solves the problem, but it is really ugly and complicated. Something
 so basic should have a much simpler solution. I think this is an annoying
 step backward in TG2 compared with TG1.

-- 
Ticket URL: <http://trac.turbogears.org/ticket/2287>
TurboGears <http://www.turbogears.org/>
TurboGears front-to-back web development

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "TurboGears Tickets" group.
This group is read-only. No posting by normal members allowed.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/turbogears-tickets?hl=en?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to