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

Peter Brand peter.brand at eines-alles-nichts.org
Fri Jul 13 13:24:22 PDT 2007


Vote:
#1 preferring better readability to less nodes.
Peter

-----Original Message-----
From: laszlo-user-bounces at openlaszlo.org
[mailto:laszlo-user-bounces at openlaszlo.org] On Behalf Of P T Withington
Sent: Wednesday, July 11, 2007 8:43 PM
To: laszlo-user at openlaszlo.org Users
Cc: OpenLaszlo development and bug reporting
Subject: [Laszlo-user] Your vote needed: Text formatting and datapaths

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!



More information about the Laszlo-user mailing list