Add wiki.checkTiddlerText() convenience method

This commit is contained in:
Jermolene 2017-02-09 15:43:28 +00:00
parent 2397f0aa6f
commit 97e995e0c7
1 changed files with 16 additions and 0 deletions

View File

@ -1106,6 +1106,22 @@ exports.getTiddlerText = function(title,defaultText) {
}
};
/*
Check whether the text of a tiddler matches a given value. By default, the comparison is case insensitive, and any spaces at either end of the tiddler text is trimmed
*/
exports.checkTiddlerText = function(title,targetText,options) {
options = options || {};
var text = this.getTiddlerText(title,"");
if(!options.noTrim) {
text = text.trim();
}
if(!options.caseSensitive) {
text = text.toLowerCase();
targetText = targetText.toLowerCase();
}
return text === targetText;
}
/*
Read an array of browser File objects, invoking callback(tiddlerFieldsArray) once they're all read
*/