The formatting string is the same as [C's `printf`](http://www.rt.com/ man/printf.3.html). The example shows that if you are just trying to concatenate separate queries into a line, using `format` is simpler. Other examples in this thread show the use of more commplex format strings to present data in a more human-readable format. E.g.,

format("You have %d items in your cart, for a total of $%6.2d", cart.itemCount, cart.total);

On 2007-07-13, at 11:50 EDT, Peter Brand wrote:

Hi all

Before beeing able to vote I should understand: How do formatting according
to #1 (using attribute 'layout') and formatting acordung to #2 (using
method 'format' and string-argument '%s %s') compare? While #1 obviously is simple layout along y-axis, I cannot see in what kind of 'formatting' is specified by the string '%s %s'. What, precisely, is that string about to
do, what's its meaning? Apologies, if that' a silly question.

Peter


-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of David Temkin
Sent: Friday, July 13, 2007 4:44 PM
To: P T Withington
Cc: [email protected] Users; OpenLaszlo development and bug
reporting
Subject: Re: [Laszlo-user] [Laszlo-dev] Your vote needed: Text
formattingand datapaths

#2 is good. Keeps things (moderately) straightforward and reduces the
amount of complexity for users and for implementors.

On Jul 11, 2007, at 11:43 AM, 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()'))"
    />



Reply via email to