1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2025-12-09 02:08:05 +00:00

Add has:index (#4540)

* has:index

* has:index

* has:index docs

* has op examples

* has op examples

* operator macros typo missing </div>

* possible mistake
This commit is contained in:
Joshua Fontany
2020-04-14 08:52:56 -07:00
committed by GitHub
parent dc82365956
commit 69c8058b72
3 changed files with 25 additions and 6 deletions

View File

@@ -3,7 +3,7 @@ title: $:/core/modules/filters/has.js
type: application/javascript
module-type: filteroperator
Filter operator for checking if a tiddler has the specified field
Filter operator for checking if a tiddler has the specified field or index
\*/
(function(){
@@ -33,7 +33,23 @@ exports.has = function(source,operator,options) {
}
});
}
} else {
}
else if(operator.suffix === "index") {
if(invert) {
source(function(tiddler,title) {
if(!tiddler || (tiddler && (!$tw.utils.hop($tw.wiki.getTiddlerDataCached(tiddler,Object.create(null)),operator.operand)))) {
results.push(title);
}
});
} else {
source(function(tiddler,title) {
if(tiddler && $tw.utils.hop($tw.wiki.getTiddlerDataCached(tiddler,Object.create(null)),operator.operand)) {
results.push(title);
}
});
}
}
else {
if(invert) {
source(function(tiddler,title) {
if(!tiddler || !$tw.utils.hop(tiddler.fields,operator.operand) || (tiddler.fields[operator.operand] === "")) {