[PATCH v2] templater: add separate() template function

Martin von Zweigbergk martinvonz at google.com
Thu May 5 00:36:14 EDT 2016


On Wed, May 4, 2016 at 8:51 PM Yuya Nishihara <yuya at tcha.org> wrote:

> On Thu, 05 May 2016 03:19:35 +0000, Martin von Zweigbergk wrote:
> > Perhaps we can extend join() after all. When given at least 3 arguments,
> > the last one can still be the separator and the ones before it are the
> > items to separate. It's a little weird to have the separator last, but it
> > does avoid the need for a new name. Thoughts?
>
> or introduce a list constructor?
>
>   join(items(node, bookmarks, tags), " ")
>   items(node, bookmarks, tags) % "{item} "
>
> No idea if it should implicitly drop empty items.
>

Right, I just remembered that point too. So a new function is probably best.

So the difference between your proposal and Matt's is when two arguments
are given and the second one is not a list, for example:

separate(" ", rev)
separate(" ", branch)

With Matt's proposal, they would be allowed (and pointless) and with your
proposal they would be disallowed. Although pointless, I think it's a small
win that separate(" ", rev, branch) can be simplified into one of the above
and still work without forcing the user to clean it up by dropping the call
to separate. Perhaps the user has a group of similar calls and wants to
keep the separate() for consistency.

Also note that, with either proposal, these two behave quite differently:

separate(":", node, branches)
separate(":", branches)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.mercurial-scm.org/pipermail/mercurial-devel/attachments/20160505/fef87cd2/attachment.html>


More information about the Mercurial-devel mailing list