mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-27 12:07:19 +00:00
Refactor utility for converting tiddlers to JSON
This commit is contained in:
parent
107b0c17c0
commit
83a245ed21
@ -26,19 +26,7 @@ exports.params = [
|
||||
Run the macro
|
||||
*/
|
||||
exports.run = function(filter) {
|
||||
var tiddlers = this.wiki.filterTiddlers(filter),
|
||||
data = [];
|
||||
for(var t=0;t<tiddlers.length; t++) {
|
||||
var tiddler = this.wiki.getTiddler(tiddlers[t]);
|
||||
if(tiddler) {
|
||||
var fields = new Object();
|
||||
for(var field in tiddler.fields) {
|
||||
fields[field] = tiddler.getFieldString(field);
|
||||
}
|
||||
data.push(fields);
|
||||
}
|
||||
}
|
||||
return JSON.stringify(data,null,$tw.config.preferences.jsonSpaces);
|
||||
return this.wiki.getTiddlersAsJson(filter);
|
||||
};
|
||||
|
||||
})();
|
||||
|
@ -623,6 +623,22 @@ exports.getTiddlerAsJson = function(title) {
|
||||
}
|
||||
};
|
||||
|
||||
exports.getTiddlersAsJson = function(filter) {
|
||||
var tiddlers = this.filterTiddlers(filter),
|
||||
data = [];
|
||||
for(var t=0;t<tiddlers.length; t++) {
|
||||
var tiddler = this.getTiddler(tiddlers[t]);
|
||||
if(tiddler) {
|
||||
var fields = new Object();
|
||||
for(var field in tiddler.fields) {
|
||||
fields[field] = tiddler.getFieldString(field);
|
||||
}
|
||||
data.push(fields);
|
||||
}
|
||||
}
|
||||
return JSON.stringify(data,null,$tw.config.preferences.jsonSpaces);
|
||||
};
|
||||
|
||||
/*
|
||||
Get the content of a tiddler as a JavaScript object. How this is done depends on the type of the tiddler:
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user