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

P T Withington ptw at openlaszlo.org
Thu Jul 12 05:02:43 PDT 2007


On 2007-07-11, at 17:28 EDT, Paulo Scardine 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... [choped]
>
> I vote #2.
>
> Reason: We have xml, javascript and ${foo} syntaxes. It's too much.
>
> <twocents>IMHO ${foo} is a nice hack (I love laszlo contraints) but  
> I would avoid using it or at least keep use very simple if  
> possible. Abusing ${foo} is asking for trouble.</twocents>

That's a good point.  Often after building an application, the first  
step to optimization is to examine your constraints and replace them  
with simpler explicit events.  I was thinking the constraint-based  
approach was really necessary to take advantage of formatting if you  
were not data-binding:

<text
   textformat="You have %d items in your cart, for a total of $%6.2d"
   data="${cart.itemCount}, ${cart.total}"
/>

But you could re-write that to use explicit events:

<text name="summary" />

<handler name="update" reference="cart">
   summary.format("You have %d items in your cart, for a total of $% 
6.2d", cart.itemCount, cart.total);
</handler>

I think the question is whether the constraint-oriented syntax is  
more helpful for prototyping.


More information about the Laszlo-user mailing list