[Laszlo-user] [Laszlo-dev] Your vote needed: Text formatting and datapaths

James Robey jrobey at laszlosystems.com
Wed Jul 11 12:28:23 PDT 2007


Wow, a major reduction in code size and removes lexically spurious  
layouts too!

Vote: #2.

Opinion:
That's the easiest of the three to recall and introduces no new  
attributes to keep track of. How it works makes sense using commonly  
known patterns. Makes clear the mechanism and invites the user to use  
the actual format() call programmatically on other nodes.

If i were king:
<text datapath="person/" text="%s %s" format="$path{'firstName/text 
()', 'lastName/text()'}" />

Opinion:
	- the use of the text attribute is retained looks as normal as possible
	- inclusion of the new functionality is orthogonal to existing code  
patterns.
	- seems easy to remember.
	- Would still have to learn both this tag and the format() function  
to fully grok it, like the other attribute fudges below.

On Jul 11, 2007, at 2:43 PM, P T Withington wrote:

> We recently added a `format` method to the text tag that allows you  
> to format the content of a text tag using the standard printf-style  
> controls.  We think this will be most useful when data binding a  
> text node.  As an example, if you have an XML dataset of people  
> with firstName and lastName nodes, you currently would display each  
> element by saying:
>
> 1.  <view datapath="person/" layout="axis: x">
>       <text text="$path{'firstName/text()'}" />
>       <text text="$path{'lastName/text()'}" />
>     </view>
>
> With the addition of the format method, you can now say this more  
> compactly, using only 1 node, instead of 3 (which is also more  
> efficient):
>
> 2.  <text datapath="person/"
>       ondata="format('%s %s', datapath.xpathQuery('firstName/text 
> ()'), datapath.xpathQuery('lastName/text()'))"
>     />
>
> When the data gets bound to the text node, you fill in the text by  
> calling format and making the two xpath queries as arguments to the  
> format method.
>
> But we are considering two other possible syntaxes:
>
> 3.  <text datapath="person/"
>       dataformat="'%s %s'"
>       data=$path{'firstName/text()', 'lastName/text()'}
>     />
>
> Here you specify a format control string for the data associated  
> with the text node, and we allow you to make multiple queries in  
> your $path constraint.
>
> 4.  <text datapath="person/" dataformat="'%{firstName/text()}1$q % 
> {lastName/text()}1$q'" />
>
> Here the queries are embedded in the control string with a custom  
> extension.
>
> Please cast your vote!
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.openlaszlo.org/pipermail/laszlo-user/attachments/20070711/574eab7b/attachment.html


More information about the Laszlo-user mailing list