FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

XML Templating

 
Post new topic   Reply to topic     Forum Index -> Sendero
View previous topic :: View next topic  
Author Message
aaronc542



Joined: 22 May 2007
Posts: 35
Location: NJ, USA

PostPosted: Mon Oct 22, 2007 11:40 am    Post subject: XML Templating Reply with quote

Some of you may have noticed that an XML templating system (with built-in string localization via ICU) was added recently. In the future, I hope to add a backend for tango.locale. To get this code fully functional, I would like to resolve a syntax questions I have.

The template system is based on Genshi (http://genshi.edgewall.org/wiki/Documentation/xml-templates.html). In Genshi, variables are referenced as follows:

Code:
The value of bar is: ${bar}


Currently, in Sendero, variables are referenced as follows:

Code:
The value of bar is: _{$bar}


The system also has some nice features for string localization. For instance:

Code:
_{$date: datetime, long}


will output the variable $date in the current locale's long datetime format via ICU. Also, function calls can go between the _{}. For instance:
Code:
_{myFunction(value)}


There is some documentation in sendero.xml.XmlTemplate and sendero.util.LocalText.

The reason for using the dollar-sign for prefixing variables is to be consistent with XPath/XQuery so that eventually the template language will be able to accept any XPath expression and format it for the current locale. I also intend to add a feature that will automatically extract all strings and put them into a .PO format for gettext-like translation.

So, what is everyone's feedback on the template language syntax?


    Do you like the _{$var} syntax?
    Do you like having a _{$var, formattingOption syntax} or would using a function call like _{fmt($var, options)} be more natural?


P.S. Don't expect the template language to compile against Mango trunk - I need to get some patches applied to Mango first.
Back to top
View user's profile Send private message
rrichardson



Joined: 10 Sep 2007
Posts: 11

PostPosted: Mon Oct 22, 2007 8:11 pm    Post subject: Reply with quote

Sounds good!

I don't think I've thought this through completely, but I like the built-in localization and formatting as part of the template call itself. This seems like it could save some headaches. If a person doesn't want to take advantage of it, then the syntax is the same.

It might be interesting to formalize the {,,} syntax into a filter/transform system.. i.e. the 1st param is the text, the 2nd param is the transform to be applied (translation, localization, allcaps, etc). Just a thought.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> Sendero All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group