mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-09-26 22:28:18 +00:00
Bugfix/3117 inconsistent each (#3124)
* Following Jeremy's proposal of using a new suffix * typo fixed
This commit is contained in:
parent
477cb0c47e
commit
5963adf92e
@ -18,18 +18,34 @@ Export our filter function
|
|||||||
*/
|
*/
|
||||||
exports.each = function(source,operator,options) {
|
exports.each = function(source,operator,options) {
|
||||||
var results =[] ,
|
var results =[] ,
|
||||||
value,values = {},
|
value,values = {},
|
||||||
field = operator.operand || "title";
|
field = operator.operand || "title";
|
||||||
if(operator.suffix !== "list-item") {
|
if(operator.suffix === "value" && field === "title") {
|
||||||
source(function(tiddler,title) {
|
source(function(tiddler,title) {
|
||||||
if(tiddler) {
|
if(!$tw.utils.hop(values,title)) {
|
||||||
value = (field === "title") ? title : tiddler.getFieldString(field);
|
values[title] = true;
|
||||||
if(!$tw.utils.hop(values,value)) {
|
results.push(title);
|
||||||
values[value] = true;
|
|
||||||
results.push(title);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
} else if(operator.suffix !== "list-item") {
|
||||||
|
if(field === "title") {
|
||||||
|
source(function(tiddler,title) {
|
||||||
|
if(tiddler && !$tw.utils.hop(values,title)) {
|
||||||
|
values[title] = true;
|
||||||
|
results.push(title);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
source(function(tiddler,title) {
|
||||||
|
if(tiddler) {
|
||||||
|
value = tiddler.getFieldString(field);
|
||||||
|
if(!$tw.utils.hop(values,value)) {
|
||||||
|
values[value] = true;
|
||||||
|
results.push(title);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
source(function(tiddler,title) {
|
source(function(tiddler,title) {
|
||||||
if(tiddler) {
|
if(tiddler) {
|
||||||
|
@ -7,5 +7,7 @@ type: text/vnd.tiddlywiki
|
|||||||
<<.operator-example 1 "[each[color]]">>
|
<<.operator-example 1 "[each[color]]">>
|
||||||
<<.operator-example 2 "[sort[title]each[type]]" "the alphabetically first tiddler of each type">>
|
<<.operator-example 2 "[sort[title]each[type]]" "the alphabetically first tiddler of each type">>
|
||||||
<<.operator-example 3 "[each:list-item[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">>
|
||||||
|
<<.operator-example 4 "[[Non existing]] [[GettingStarted]] +[each:value[]]" "Compare this to `+[each[]]` below">>
|
||||||
|
<<.operator-example 5 "[[Non existing]] [[GettingStarted]] +[each[]]" "Compare this to `+[each:value[]]` above">>
|
||||||
|
|
||||||
For an example of using the <<.op each>> operator to generate a two-tier list of groups and members, see [[GroupedLists]].
|
For an example of using the <<.op each>> operator to generate a two-tier list of groups and members, see [[GroupedLists]].
|
||||||
|
Loading…
Reference in New Issue
Block a user