You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by "Howard M. Lewis Ship (JIRA)" <de...@tapestry.apache.org> on 2008/01/20 19:34:35 UTC

[jira] Commented: (TAPESTRY-2043) Loop component could provide a parameter for delimiting its body for each iteration

    [ https://issues.apache.org/jira/browse/TAPESTRY-2043?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12560837#action_12560837 ] 

Howard M. Lewis Ship commented on TAPESTRY-2043:
------------------------------------------------

Given the basic rule "zero false, anything else is true", you could accomplish this today as:

<t:loop source="strings" value="var:string" index="var:index">
  <t:if test="var:index ">,</t:if>
  <a href="#" t:type="pagelink" page="nada" context="var:string">${var:string}</a>
</t:loop>

This is a useful bit of functionality, but is it really universal and fundamental enough to be incorporated directly into the Loop component, or is it really something that should be encapsulated in your own DelimitedLoop component?



> Loop component could provide a parameter for delimiting its body for each iteration
> -----------------------------------------------------------------------------------
>
>                 Key: TAPESTRY-2043
>                 URL: https://issues.apache.org/jira/browse/TAPESTRY-2043
>             Project: Tapestry
>          Issue Type: Improvement
>          Components: Core Components, tapestry-core
>    Affects Versions: 5.0, 5.0.8
>            Reporter: Chris Lewis
>
> There are cases where one needs to output a list of data and delimit the items. In a simple situations, and in a world with perfect browsers, we could use CSS2 pseudo selectors to tack on trailng characters. In reality this is not an option, at least not now. Say a page has a list of strings like so:
> { "one", "two", "three" }
> The desired output is:
> one, two, three
> Currently this is not possible using the loop component. There are at least 2 solutions that could be implemented, each of which was suggested on the mailing list. The first is to improve the 'language' used by T5 to support more tests:
> <t:loop source="strings" value="var:string" index="var:index">
>   <a href="#" t:type="pagelink" page="nada" context="var:string">${var:string}</a>
>   <t:if test="var:index < strings.size()">,</t:if>
> </t:loop>
> I'm under the impression that the language will be improved to do such things, but in my opinion this delimiting function is a common enough need to recognized it by a parameter in the Loop component proper:
> <t:loop source="strings" value="var:string" delimiter=", ">
>   <a href="#" t:type="pagelink" page="nada" context="var:string">${var:string}</a>
> </t:loop>
> The logic would ensure that the output is only delimited and not create leading or trailing characters (if need they can be inserted outside of the component).

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tapestry.apache.org
For additional commands, e-mail: dev-help@tapestry.apache.org