On Jun 27, 2007, at 8:00 PM, Noah Gift wrote:

> How will the template play into the toscawidget design.  Ideally, a  
> widget could be written and used without the template language  
> being involved, is this always the case?  If not there will not be  
> a 100% toscawidget API between Pylons and Turbogears as it is  
> Genshi vs Mako

Widgets themselves don't know anything about their template. The just  
populate a dict and push it to the EngineManager, which, based on the  
widget's engine_name and template attributes, determine which  
engine'template to rebder that dict with.

This means that as long as the templates are equivalent (produce  
roughly the same html output), then engines can be swapped freely.

For example, this is twForms TextField's code:

class TextField(InputField):
     """A text field"""
     params = ["size", "max_size"]
     size__doc = "The size of the text field."
     size__doc = "The maximum size of the field"
     type = "text"
     def update_params(self,d):
         super(TextField, self).update_params(d)
         self.update_attrs(d, "size", "max_size")

(template is inheritted from InputField)

and this is the (genshi) template:

<input xmlns="http://www.w3.org/1999/xhtml";
        xmlns:py="http://genshi.edgewall.org/";
        type="${type}" name="${name}" class="${css_class}" id="${id}"
        value="${value}"
        py:attrs="attrs" />

To make a textfield that used Mako you'll just need to make a mako  
equivalent template for the above and stick it into a TextField  
subclass:

class MakoTextField(TextField):
        engine = "mako:path.to.template"

I've already mentioned this in TW's mailing list but it's worth  
repeating:

I'm open to contrubutions for Mako equivalent templates to bundle  
them with twForms. That will allow me to remove the Genshi dependency  
and provide both mako and genshi as extras_requires so users could  
choose.

Alberto

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" 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?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to