1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-12-26 01:50:28 +00:00

Update the include macro to use filtering and serializing

This commit is contained in:
Jeremy Ruston 2012-05-05 13:15:59 +01:00
parent a753509cbf
commit e3524942cc

View File

@ -13,23 +13,24 @@ module-type: macro
exports.info = { exports.info = {
name: "^", name: "^",
params: { params: {
target: {byPos: 0, type: "tiddler"}, filter: {byPos: 0, type: "filter"},
as: {byPos: 1, as: "text"} as: {byPos: 1, as: "text"}
} }
}; };
exports.executeMacro = function() { exports.executeMacro = function() {
var tiddler = this.hasParameter("target") ? this.wiki.getTiddler(this.params.target) : null, var as = this.params.as || "text/plain";
as = this.params.as, if(this.hasParameter("filter")) {
children = []; var titles = this.wiki.filterTiddlers(this.params.filter),
if(tiddler) { result = [];
as = as || tiddler.fields.as || "text/plain"; for(var t=0; t<titles.length; t++) {
children = this.wiki.parseText(as,tiddler.fields.text).tree; result.push(this.wiki.serializeTiddler(this.params.filter,as));
for(var t=0; t<children.length; t++) {
children[t].execute(this.parents,this.tiddlerTitle);
} }
return [$tw.Tree.Element("pre",{},[
$tw.Tree.Text(result.join("\n"))
])];
} }
return children; return [];
}; };