Merge pull request #2073 from tobibeer/each-list

change suffix each:list to each:list-item
print-window-tiddler
Jeremy Ruston 2015-11-13 10:10:36 +00:00
commit 3a33282705
4 zmienionych plików z 6 dodań i 6 usunięć

Wyświetl plik

@ -20,7 +20,7 @@ exports.each = function(source,operator,options) {
var results =[] ,
value,values = {},
field = operator.operand || "title";
if(operator.suffix !== "list") {
if(operator.suffix !== "list-item") {
source(function(tiddler,title) {
if(tiddler) {
value = (field === "title") ? title : tiddler.getFieldString(field);

Wyświetl plik

@ -219,8 +219,8 @@ describe("Filter tests", function() {
it("should handle the each operator", function() {
expect(wiki.filterTiddlers("[each[modifier]sort[title]]").join(",")).toBe("$:/TiddlerTwo,TiddlerOne");
expect(wiki.filterTiddlers("[each:list[tags]sort[title]]").join(",")).toBe("one,two");
expect(wiki.filterTiddlers("[each:list[authors]sort[title]]").join(",")).toBe("Bloggs,Joe,John Doe");
expect(wiki.filterTiddlers("[each:list-item[tags]sort[title]]").join(",")).toBe("one,two");
expect(wiki.filterTiddlers("[each:list-item[authors]sort[title]]").join(",")).toBe("Bloggs,Joe,John Doe");
});
it("should handle the eachday operator", function() {

Wyświetl plik

@ -6,7 +6,7 @@ type: text/vnd.tiddlywiki
caption: each
op-purpose: select one of each group of input titles by field
op-input: a [[selection of titles|Title Selection]]
op-suffix: optionally, `list`
op-suffix: optionally, `list-item`
op-parameter: the name of a [[field|TiddlerFields]], defaulting to <<.field title>>
op-parameter-name: F
op-output: a selection containing the first input title encountered for each distinct value of field <<.place F>>
@ -15,7 +15,7 @@ Each input title is processed in turn. The value of field <<.place F>> in the co
;each
:As long as the field's value has not been encountered before, the title is appended to the output.
;each:list
;each:list-item
:The value is treated as a [[title list|Title List]]. Each title in the list considered in turn. If it has not been encountered before, it is appended to the output.
If a tiddler doesn't contain field <<.place F>>, it is treated as if the field's value was empty.

Wyświetl plik

@ -6,6 +6,6 @@ type: text/vnd.tiddlywiki
<<.operator-example 1 "[each[color]]">>
<<.operator-example 2 "[sort[title]each[type]]" "the alphabetically first tiddler of each type">>
<<.operator-example 3 "[each:list[list]]" "all tiddlers listed anywhere in the core list field">>
<<.operator-example 3 "[each:list-item[list]]" "all tiddlers listed anywhere in the core list field">>
For an example of using the <<.op each>> operator to generate a two-tier list of groups and members, see [[GroupedLists]].