I should have an easy way to "cut" long lists
Summary: This is a request from Eric, which needs some thought.
Eric's request from email, 2/8/16:
The use-case I have isn't a pagination one, though; it's closer to something like an LJ-cut. If you look at the page
https://querki.net/u/darker/spirit-island-faq/#!All-Errata-and-FAQ-Entries
you'll see a list of FAQ entries, each of which has tags along the bottom. I want to trim down immense tag-lists, but make it clear there are many more. Without this trimming, the straightforward QL
[[_concat(References Items, References Concepts) -> _commas]]
gets me the tags. To do the conditional trim + "N more...", I instead have to use
[[_if(_greaterThan(4, _concat(References Items, References Concepts) -> _count),
_concat(References Items, References Concepts) -> _commas,
""[[_concat(References Items, References Concepts) -> _take(4) -> _commas]], [[_showLink(""[[_concat(References Items, References Concepts) -> _count]] more..."")]]
...which was 1-2 orders of magnitude harder to put together.
(Obviously, I don't *need* the syntactic sugar, having hacked it together as-is, but it might be nice for others - or for me, when I try to come back to my code later? The combo of "QText cares about whitespace" and "QL has no comments" makes return-to-it readability pretty low, which in turn makes concise code even more valuable than usual.)
The interesting question is, what's the abstraction? Roughly speaking, it's "do X with the first N elements, show message M as a clickable link if there are more, and do Y if clicked". Is that generally useful enough to be worth building in? Can this higher-level function be written in QL? (It should be written in QL, so it's worth trying.)
The analogy to LJ-cut is helpful for thinking about this; might also think about LJ-spoiler as another desireable approach, which might actually be a little easier. (In that the in-place version wouldn't require the separate Y -- you'd simply continue X for the rest of the elements if clicked.) Possibly both could be done with one function, depending on whether or not Y is specified?